Cara Membuat Website Pembelian Tiket Pesawat dengan PHP dan SQL
Dalam sebuah system e-commerce tentunya harus terdapat database yang dapat menangani beberapa hal seperti: menangani database produk yang akan dijual, menangani pencatatan order yang masuk, produk apa yang di pesan, seberapa banyak produk tersebut dipesan.
Tabel- Tabel dalam database yang kita perlukan untuk membuat Pembelian Tiket Pesawat :
Tentu saja kita membutuhkan codingan PHP untuk membuat struktur design.
Codingan yang akan kita perlukan :
1. koneksi.php
2.Tampilan User : - index.php
- login.php
- register.php
- pesanan.php
- logout.php
- booking.php
3. Tampilan Petugas : - login.php
- petugas.php
4. Tampilan Admin : - login.php
- tambah_penerbangan.php
- data_penerbangan.php
- edit_penerbangan.php
Koneksi.php
<?php
session_start();
/**
* Isi dengan detail database.
*/
$db_host = 'localhost';
$db_user = 'root';
$db_pass = '';
$db_name = 'usk_native';
/**
* Cek koneksi ke database
*/
$connect = new mysqli($db_host, $db_user, $db_pass, $db_name);
if($connect->errno) {
echo $connect->error;
exit;
}
?>
index.php
<?php
include "./core/libcore_backend.php";
$core = new Libcore();
$core->connect();
$core->isUserLogin();
$data = $core->getFlightList();
$x = $core->getUser($_COOKIE["user"]);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Online - RESERVASI PESAWAT</title>
<link href="./styles/bootstrap.min.css" rel="stylesheet">
<link href="./styles/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: rgba(60,160, 60,0.8);">
<div class="container-fluid ps-5">
<a class="navbar-brand" href="#">Tiket Online</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav w-100 ms-auto" style="float: right;">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Form Pemesanan</a>
</li>
<li class="nav-item w-75">
<a class="nav-link" aria-current="page" href="pesanan.php">Tiket Saya</a>
</li>
<li class="nav-item dropdown" style="margin-left: 3%;">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<?= $x["nama"] ?>
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="login.php">Logout</a></li>
<li><a class="dropdown-item" href="admin/login.php">Login Admin</a></li>
<li><a class="dropdown-item" href="petugas/login.php">Login Staff</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-5 d-flex">
<?php foreach ($data as $flight) : ?>
<div class="col-md-3 mb-4 h-50 m-1">
<div class="card" style="height: 550px;">
<div class="card-body">
<img src="./public/foto/<?= $flight['foto']; ?>" class="card-img-top" alt="..." height="250">
<h5 class="card-title mb-0"><?= $flight['maskapai'] ?> #<?= $flight['flight_id'] ?></h5>
<p class="text-muted mb-3 h6"><?= $flight['bandara_asal'] ?> - <?= $flight['tujuan_akhir'] ?></p>
Jam Penerbangan: <?= $flight['tanggal_penerbangan'] ?><br>
Quota: <?= $flight['kuota'] ?><br>
<!-- Add other data fields as needed -->
<!-- Example: -->
Sektor: <?= $flight['sektor'] ?><br>
Waktu Kedatangan: <?= $flight['jam_kedatangan'] ?>
</p>
<!-- Add more fields as needed -->
<form method="post" action="booking.php">
<input name="id" value="<?= $flight['flight_id'] ?>" type="hidden">
<hr>
<small class="text-muted">harga: Rp<?= $flight['harga'] ?></small>
<button class="btn btn-success w-100">Pesan Tiket</a>
</form>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<script src="./styles/bootstrap.bundle.min.js"></script>
</body>
</html>
login.php
<?php
include "./core/libcore_backend.php";
$core = new Libcore();
$core->connect();
$msg = '<div class="alert alert-warning p-2"><small>Masuk ke akun anda</small></div>';
if(isset($_POST["user"]) && isset($_POST["pass"])) {
if($core->loginUser($_POST["user"], $_POST["pass"])){
header("Location: index.php");
}
else {
$msg = '<div class="alert alert-danger p-2"><small>Email atau Passsword salah</small></div>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Online - Login</title>
<link href="./styles/bootstrap.min.css" rel="stylesheet">
<link href="./styles/styles.css" rel="stylesheet">
</head>
<body class="container" style="background-image: url(./image/background.jpg); background-repeat: no-repeat;background-size: cover;">
<center>
<form class=" p-3" action="" style="max-width: 500px;border: 2px solid #eee;border-radius: 10px;margin-top: 25vh;background: rgba(255,255,255,0.8)" method="post">
<center><h3 class="mb-0">Tiket Online</h3></center>
<small class="text-muted">Pelayanan cepat harga merakyat</small>
<hr>
<?= $msg; ?>
<input class="form-control" placeholder="Email" name="user">
<input class="form-control mt-3" placeholder="Password" name="pass">
<button class="btn btn-success mt-3 w-100">Login</button>
<hr>
<a href="register.php">Klik untuk mendaftar akun</a>
</form>
</center>
</body>
</html>
register.php
<?php
include "./core/libcore_backend.php";
$core = new Libcore();
$core->connect();
if(isset($_POST["nama"]) && isset($_POST["email"]) && isset($_POST["pass"])) {
$x = $core->registerUser($_POST["nama"], $_POST["email"], $_POST["pass"]);
if($x){
$msg = '<div class="alert alert-success p-2"><small>Akun telah dibuat </small></div>';
}
else {
if($x){
$msg = '<div class="alert alert-success p-2"><small>Akun gagal dibuat </small></div>';
}
}
}
$msg = '<div class="alert alert-warning p-2"><small>Registrasi Akun</small></div>';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Online - Register</title>
<link href="./styles/bootstrap.min.css" rel="stylesheet">
<link href="./styles/styles.css" rel="stylesheet">
</head>
<body class="container" style="background-image: url(./image/background.jpg); background-repeat: no-repeat;background-size: cover;">
<center>
<form class=" p-3" action="" style="max-width: 500px;border: 2px solid #eee;border-radius: 10px;margin-top: 20vh;background: rgba(255,255,255,0.8)" method="post">
<center><h3 class="mb-0">Tiket Online</h3></center>
<small class="text-muted">Pelayanan cepat harga merakyat</small>
<hr>
<?= $msg; ?>
<input class="form-control mt-3 w-100" placeholder="Nama" name="nama">
<div class="d-flex justify-content-start"><small class="text-muted" style="text-align: start;">Masukkan nama depan dan belakang anda</small></div>
<input class="form-control mt-3" placeholder="Email" name="email" type="email">
<div class="d-flex justify-content-start"><small class="text-muted" style="text-align: start;">Masukkan email yang valid (harus memiliki simbol '@')</small></div>
<input class="form-control mt-3" placeholder="Password" name="pass">
<div class="d-flex justify-content-start"><small class="text-muted" style="text-align: start;">Masukkan password yang ingin digunakan</small></div>
<button class="btn btn-success mt-3 w-100">Register</button>
<hr>
<a href="login.php">Klik jika sudah mempunyai akun</a>
</form>
</center>
</body>
</html>
pesanan.php
<?php
include "./core/libcore_backend.php";
$core = new Libcore();
$core->connect();
$core->isUserLogin();
$x = $core->getUser($_COOKIE["user"]);
$data = $core->getTicket($x["user_id"]);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Onlne - RESERVASI PESAWAT</title>
<link href="./styles/bootstrap.min.css" rel="stylesheet">
<link href="./styles/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: rgba(60,160, 60,0.8);">
<div class="container-fluid ps-5">
<a class="navbar-brand" href="#">Tiket Onlne</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav w-100 ms-auto" style="float: right;">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="index.php">Form Pemesanan</a>
</li>
<li class="nav-item w-75">
<a class="nav-link active" aria-current="page" href="pesanan.php">Tiket Saya</a>
</li>
<li class="nav-item dropdown" style="margin-left: 3%;">
<a class="nav-link active dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<?= $x["nama"] ?>
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">Logout</a></li>
<li><a class="dropdown-item" href="admin/login.php">Login Adminf</a></li>
<li><a class="dropdown-item" href="petugas/login.php">Login Staff</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-5 ">
<h4 class="text-muted">User Area > Ticket Status</h4>
<table class="table table-sm table-striped table-bordered">
<thead>
<tr>
<th>Maskapai</th>
<th>Tujuan</th>
<th>Sektor</th>
<th>Tanggal Penerbangan</th>
<th>Jam Kedatangan</th>
<th>Jam Keberangkatan</th>
<th>Jam Tiba</th>
<th>Kode PNR</th>
<th>Harga</th>
<th>Konfirmasi</th>
</tr>
</thead>
<tbody>
<tr>
<?php
foreach ($data as $f) :
?>
<td><?= $f["maskapai"] ?></td>
<td><?= $f["bandara_asal"] ?> - <?= $f["tujuan_akhir"] ?> </td>
<td><?= $f["sektor"] ?></td>
<td><?= $f["tanggal_penerbangan"] ?></td>
<td><?= $f["jam_kedatangan"] ?></td>
<td><?= $f["jam_berangkat"] ?></td>
<td><?= $f["jam_tiba"] ?></td>
<td><?= $f["kode_pnr"]; ?></td>
<td><?= $f["harga"] ?></td>
<td><?= $f["konfirmasi"] == 0 ? "<small class='text-danger'>belum</small>" : "<a class='btn btn-sm btn-success'>Cetak tiket</a>"; ?></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</div>
<script src="./styles/bootstrap.bundle.min.js"></script>
</body>
</html>
logout.php
<?php
$currentPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$p= dirname($currentPath);
setcookie("user", "", time() - 3600, "$p/");
setcookie("pass", "", time() - 3600, "$p/");
setcookie("user", "", time() - 3600);
setcookie("pass", "", time() - 3600);
setcookie("user", "", time() - 3600, "$p/admin");
setcookie("pass", "", time() - 3600, "$p/admin");
setcookie("user", "", time() - 3600, "$p/petugas");
setcookie("pass", "", time() - 3600, "$p/petugas");
header("Location: index.php");
?>
booking.php
<?php
include "./core/libcore_backend.php";
$core = new Libcore();
$core->connect();
$core->isUserLogin();
$x = $core->getUser($_COOKIE["user"]);
if (isset($_POST["id"])) {
$f = $core->getFlight($_POST["id"]);
}
$arr = [];
$tickets = [];
$kode_pnr = uniqid();
$date = new DateTime("now");
$core->insertTicket(
intval($x["user_id"]),
$kode_pnr,
$date->format("Y-m-d"),
$_POST["id"]
);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Onlne - RESERVASI PESAWAT</title>
<link href="./styles/bootstrap.min.css" rel="stylesheet">
<link href="./styles/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: rgba(60,160, 60,0.8);">
<div class="container-fluid ps-5">
<a class="navbar-brand" href="#">Tiket Onlne</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav w-100 ms-auto" style="float: right;">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Form Pemesanan</a>
</li>
<li class="nav-item w-75">
<a class="nav-link" aria-current="page" href="pesanan.php">Tiket Saya</a>
</li>
<li class="nav-item dropdown" style="margin-left: 3%;">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<?= $x["nama"] ?>
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="#">Logout</a></li>
<li><a class="dropdown-item" href="admin/login.php">Login Staff</a></li>
<li><a class="dropdown-item" href="petugas/login.php">Login Admin</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-5">
<center>
<h4>Pemesanan selesai</h4>
</center>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Maskapai</th>
<th>Tujuan</th>
<th>Sektor</th>
<th>Tanggal Penerbangan</th>
<th>Jam Kedatangan</th>
<th>Jam Keberangkatan</th>
<th>Jam Tiba</th>
<th>Kode PNR</th>
<th>Harga</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= $f["maskapai"] ?></td>
<td><?= $f["bandara_asal"] ?> - <?= $f["tujuan_akhir"] ?> </td>
<td><?= $f["sektor"] ?></td>
<td><?= $f["tanggal_penerbangan"] ?></td>
<td><?= $f["jam_kedatangan"] ?></td>
<td><?= $f["jam_berangkat"] ?></td>
<td><?= $f["jam_tiba"] ?></td>
<td><?= $kode_pnr; ?></td>
<td><?= $f["harga"] ?></td>
</tr>
</tbody>
</table>
<center><a class="btn btn-success" href="pesanan.php">cek status konfirmasi tiket</a></center>
</div>
</body>
</html>
Tampilan Petugas
login.php
<?php
include "./../core/libcore_backend.php";
$core = new Libcore();
$core->connect();
$msg = '<div class="alert alert-warning p-2"><small>Masuk ke akun staff</small></div>';
if(isset($_POST["user"]) && isset($_POST["pass"])) {
if($core->loginStaff($_POST["user"], $_POST["pass"])){
header("Location: petugas.php");
}
else {
$msg = '<div class="alert alert-danger p-2"><small>Email atau Passsword salah</small></div>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Onlne - LOGIN</title>
<link href="./../styles/bootstrap.min.css" rel="stylesheet">
<link href="./../styles/styles.css" rel="stylesheet">
</head>
<body class="container" style="background-image: url(./../image/ryan_air.jpeg); background-repeat: no-repeat;background-size: cover;">
<center>
<form class=" p-3" action="" style="max-width: 500px;border: 2px solid #eee;border-radius: 10px;margin-top: 25vh;background: rgba(255,255,255,0.8)" method="post">
<center><h3 class="mb-0">Tiket Onlne </h3></center>
<small class="text-muted">Pelayanan cepat harga merakyat</small>
<hr>
<?= $msg; ?>
<input class="form-control" placeholder="Email" name="user">
<input class="form-control mt-3" placeholder="Password" name="pass">
<button class="btn btn-success mt-3 w-100">Login</button>
</form>
</center>
</body>
</html>
petugas.php
<?php
include "./../core/libcore_backend.php";
$core = new Libcore();
$core->connect();
$core->isStaffLogin();
$x = $core->getUser($_COOKIE["user"]);
if(isset($_GET["confirm"])){
$core->confirmTicket(intval( $_GET["confirm"]));
}
$data = $core->getTicketList();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Onlne - STAFF AREA</title>
<link href="./../styles/bootstrap.min.css" rel="stylesheet">
<link href="./../styles/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: rgba(60,50, 60,0.8);">
<div class="container-fluid ps-5">
<a class="navbar-brand" href="#">Tiket Onlne<small><i>staff</i></small></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav w-100 ms-auto" style="float: right;">
<li class="nav-item" style="width: 85%;">
<a class="nav-link active" aria-current="page" href="petugas.php">Konfirmasi Tiket</a>
</li>
<li class="nav-item dropdown" style="margin-left: 3%;">
<a class="nav-link active dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<?= $x["nama"] ?>
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="./../logout.php">Logout</a></li>
<li><a class="dropdown-item" href="./../admin/login.php">Login to Admin</a></li>
<li><a class="dropdown-item" href="./../petugas/login.php">Login to Staff</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-4 ">
<h4 class="text-muted">Staff Area > Ticket Confirmation</h4>
<table class="table table-sm table-striped table-bordered">
<thead>
<tr>
<th>Atas nama</th>
<th>Maskapai</th>
<th>Tgl. Dipesan</th>
<th>Tujuan</th>
<th>Sektor</th>
<th>Tgl. Penerbangan</th>
<th>Jam Kedatangan</th>
<th>Jam Keberangkatan</th>
<th>Jam Tiba</th>
<th>Kode PNR</th>
<th>Harga</th>
<th>Konfirmasi</th>
</tr>
</thead>
<tbody>
<tr>
<?php
foreach ($data as $f) :
?>
<td><?= $f["nama"] ?></td>
<td><?= $f["maskapai"] ?></td>
<td><?= $f["tanggal"] ?></td>
<td><?= $f["bandara_asal"] ?> - <?= $f["tujuan_akhir"] ?> </td>
<td><?= $f["sektor"] ?></td>
<td><?= $f["tanggal_penerbangan"] ?></td>
<td><?= $f["jam_kedatangan"] ?></td>
<td><?= $f["jam_berangkat"] ?></td>
<td><?= $f["jam_tiba"] ?></td>
<td><?= $f["kode_pnr"]; ?></td>
<td><?= $f["harga"] ?></td>
<td><?= $f["konfirmasi"] == 0 ? "<a class='btn btn-sm btn-success' href='?confirm=".$f['order_id']."'>Konfirmasi</a>" : "<small class='text-muted'>Sudah Dikonfirmasi</small>"; ?></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</div>
<script src="./../styles/bootstrap.bundle.min.js"></script>
</body>
</html>
Tampilan Admin
login.php
<?php
include "./../core/libcore_backend.php";
$core = new Libcore();
$core->connect();
$msg = '<div class="alert alert-warning p-2"><small>Masuk ke akun Admin</small></div>';
if(isset($_POST["user"]) && isset($_POST["pass"])) {
if($core->loginAdmin($_POST["user"], $_POST["pass"])){
header("Location: data_penerbangan.php");
}
else {
$msg = '<div class="alert alert-danger p-2"><small>Email atau Passsword salah</small></div>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Online - LOGIN</title>
<link href="./../styles/bootstrap.min.css" rel="stylesheet">
<link href="./../styles/styles.css" rel="stylesheet">
</head>
<body class="container" style="background-image: url(./../image/ryan_air.jpeg); background-repeat: no-repeat;background-size: cover;">
<center>
<form class=" p-3" action="" style="max-width: 500px;border: 2px solid #eee;border-radius: 10px;margin-top: 25vh;background: rgba(255,255,255,0.8)" method="post">
<center><h3 class="mb-0">Tiket Online </h3></center>
<small class="text-muted">Pelayanan cepat harga merakyat</small>
<hr>
<?= $msg; ?>
<input class="form-control" placeholder="Email" name="user">
<input class="form-control mt-3" placeholder="Password" name="pass">
<button class="btn btn-success mt-3 w-100">Login</button>
</form>
</center>
</body>
</html>
tambah_penerbangan.php
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
include "./../core/libcore_backend.php";
$core = new Libcore();
$core->connect();
$core->isAdminLogin();
$msg = "";
$x = $core->getUser($_COOKIE["user"]);
if (isset($_POST["maskapai"])) {
if ($core->insertFlight($_POST, $_FILES["foto"]))
$msg = '<div class="alert alert-success p-2"><small>Data penerbangan telah dibuat </small></div>';
else
$msg = '<div class="alert alert-success p-2"><small>Data penerbangan gagal dibuat </small></div>';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Online - RESERVASI PESAWAT</title>
<link href="./../styles/bootstrap.min.css" rel="stylesheet">
<link href="./../styles/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: rgba(0,0, 0,0.8);">
<div class="container-fluid ps-5">
<a class="navbar-brand" href="#">Tiket Online<small><i>staff</i></small></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav w-100 ms-auto" style="float: right;">
<li class="nav-item"">
<a class="nav-link" aria-current="page" href="data_penerbangan.php">Data</a>
</li>
<li class="nav-item" style="width: 85%;">
<a class="nav-link active" aria-current="page" href="tambah_penerbangan.php">Tambah Penerbangan</a>
</li>
<li class="nav-item dropdown" style="margin-left: 3%;">
<a class="nav-link active dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<?= $x["nama"] ?>
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="./../logout.php">Logout</a></li>
<li><a class="dropdown-item" href="./../admin/login.php">Login to Admin</a></li>
<li><a class="dropdown-item" href="./../petugas/login.php">Login to Staff</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-3">
<h3 class="text-muted">Admin area > Tambah Penerbangan</h3>
<div class="container p-3" style="border: 2px solid #eee;border-radius: 10px">
<?= $msg ?>
<form method="post" action="tambah_penerbangan.php" enctype="multipart/form-data">
<!-- Dropdown for Maskapai -->
<div class="mb-3">
<label for="maskapai" class="form-label">Maskapai</label>
<select class="form-select" id="maskapai" name="maskapai" required>
<option value="Ryan Air">Ryan Air</option>
<option value="Batik Air">Batik Air</option>
<option value="EasyJet">EasyJet</option>
<option value="Citilink">Citilink</option>
<option value="Garuda ID">Garuda Indonesia</option>
<option value="Indonesia AS">Indonesia AirAsia</option>
<option value="Lion Air">Lion Air</option>
<option value="Sriwijaya Air">Sriwijaya Air</option>
</select>
</div>
<!-- Date input for Tanggal Penerbangan -->
<div class="mb-3">
<label for="tanggal_penerbangan" class="form-label">Tanggal Penerbangan</label>
<input type="date" class="form-control" id="tanggal_penerbangan" name="tanggal_penerbangan" required>
</div>
<!-- Number input for Kuota -->
<div class="mb-3">
<label for="kuota" class="form-label">Kuota</label>
<input type="number" class="form-control" id="kuota" name="kuota" required>
</div>
<!-- Time input for Jam Kedatangan -->
<div class="mb-3">
<label for="jam_kedatangan" class="form-label">Jam Kedatangan</label>
<input type="time" class="form-control" id="jam_kedatangan" name="jam_kedatangan" required>
</div>
<!-- Text input for bandara asal -->
<div class="mb-3">
<label for="tujuan_akhir" class="form-label">Bandara Asal</label>
<input type="text" class="form-control" id="bandara_asal" name="bandara_asal" required>
</div>
<!-- Text input for Tujuan Akhir -->
<div class="mb-3">
<label for="tujuan_akhir" class="form-label">Tujuan</label>
<input type="text" class="form-control" id="tujuan_akhir" name="tujuan_akhir" required>
</div>
<!-- Text input for Sektor -->
<div class="mb-3">
<label for="sektor" class="form-label">Sektor</label>
<input type="text" class="form-control" id="sektor" name="sektor" required>
</div>
<!-- Number input for Harga -->
<div class="mb-3">
<label for="harga" class="form-label">Harga</label>
<input type="number" class="form-control" id="harga" name="harga" required>
</div>
<!-- Time input for Jam Berangkat -->
<div class="mb-3">
<label for="jam_berangkat" class="form-label">Jam Berangkat</label>
<input type="time" class="form-control" id="jam_berangkat" name="jam_berangkat" required>
</div>
<!-- Time input for Jam Tiba -->
<div class="mb-3">
<label for="jam_tiba" class="form-label">Jam Tiba</label>
<input type="time" class="form-control" id="jam_tiba" name="jam_tiba" required>
</div>
<div class="mb-3">
<label for="jam_tiba" class="form-label">Foto</label>
<input type="file" class="form-control" id="foto" name="foto" required>
</div>
<!-- Submit button -->
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
<script src="./../styles/bootstrap.bundle.min.js"></script>
</body>
</html>
data_penerbangan.php
<?php
include "./../core/libcore_backend.php";
$core = new Libcore();
$core->connect();
$core->isAdminLogin();
if(isset($_GET["del"])){
if($core->deleteFlight($_GET["del"])) echo "<script>alert('Data telah dihapus')</script>";
}
$data = $core->getFlightList();
$x = $core->getUser($_COOKIE["user"]);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Online - RESERVASI PESAWAT</title>
<link href="./../styles/bootstrap.min.css" rel="stylesheet">
<link href="./../styles/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: rgba(0,0, 0,0.8);">
<div class="container-fluid ps-5">
<a class="navbar-brand" href="#">Tiket Online<small><i>staff</i></small></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav w-100 ms-auto" style="float: right;">
<li class="nav-item" >
<a class="nav-link active" aria-current="page" href="data_penerbangan.php">Data</a>
</li>
<li class="nav-item" style="width: 85%;">
<a class="nav-link" aria-current="page" href="tambah_penerbangan.php">Tambah Penerbangan</a>
</li>
<li class="nav-item dropdown" style="margin-left: 3%;">
<a class="nav-link active dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<?= $x["nama"] ?>
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="./../logout.php">Logout</a></li>
<li><a class="dropdown-item" href="./../admin/login.php">Login to Admin</a></li>
<li><a class="dropdown-item" href="./../petugas/login.php">Login to Staff</a></li>
</ul>
</li>
</ul>
</div>
</div></nav>
<div class="container mt-5">
<h2>Flight Data</h2>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Maskapai</th>
<th>Tanggal Penerbangan</th>
<th>Kuota</th>
<th>Bandara Asal</th>
<th>Jam Kedatangan</th>
<th>Tujuan Akhir</th>
<th>Sektor</th>
<th>Harga</th>
<th>Jam Berangkat</th>
<th>Jam Tiba</th>
<th>Image</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($data as $flight) : ?>
<tr>
<td><?= strval($flight['maskapai']); ?></td>
<td><?= strval( $flight['tanggal_penerbangan']); ?></td>
<td><?= strval( $flight['kuota']); ?></td>
<td><?= $flight['bandara_asal']; ?></td>
<td><?= $flight['jam_kedatangan']; ?></td>
<td><?= $flight['tujuan_akhir']; ?></td>
<td><?= $flight['sektor']; ?></td>
<td><?= $flight['harga']; ?></td>
<td><?= $flight['jam_berangkat']; ?></td>
<td><?= $flight['jam_tiba']; ?></td>
<td><img src="./../public/foto/<?= $flight['foto']; ?>" width="100" height="100"> </td>
<td><a class="btn btn-success btn-sm m-1" href="edit_penerbangan.php?id=<?= $flight['flight_id']; ?>">Edit</a><a class="btn btn-danger btn-sm m-1" href="?del=<?= $flight['flight_id'] ?>">Hapus</a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<script src="./../styles/bootstrap.bundle.min.js"></script>
</div>
</body>
</html>
edit_penerbangan.php
<?php
include "./../core/libcore_backend.php";
$core = new Libcore();
$core->connect();
$core->isAdminLogin();
$f = $core->getFlight($_GET["id"]);
$msg = "";
if (isset($_POST["maskapai"]) && isset($_GET["edit"])) {
if ($core->editFlight($_POST, $_GET["id"]))
$msg = '<div class="alert alert-success p-2"><small>Data telah di edit </small></div>';
else
$msg = '<div class="alert alert-success p-2"><small>Data gagal di edit </small></div>';
}
$x = $core->getUser($_COOKIE["user"]);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tiket Online - RESERVASI PESAWAT</title>
<link href="./../styles/bootstrap.min.css" rel="stylesheet">
<link href="./../styles/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: rgba(0,0, 0,0.8);">
<div class="container-fluid ps-5">
<a class="navbar-brand" href="#">Tiket Online<small><i>staff</i></small></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav w-100 ms-auto" style="float: right;">
<li class="nav-item" >
<a class="nav-link active" aria-current="page" href="data_penerbangan.php">Data</a>
</li>
<li class="nav-item" style="width: 85%;">
<a class="nav-link" aria-current="page" href="tambah_penerbangan.php">Tambah Penerbangan</a>
</li>
<li class="nav-item dropdown" style="margin-left: 3%;">
<a class="nav-link active dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<?= $x["nama"] ?>
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="./../logout.php">Logout</a></li>
<li><a class="dropdown-item" href="./../admin/login.php">Login to Admin</a></li>
<li><a class="dropdown-item" href="./../petugas/login.php">Login to Staff</a></li>
</ul>
</li>
</ul>
</div>
</div></nav>
<div class="container mt-5">
<div class="container mt-5 m-5 p-3" style="border: 2px solid #eee;border-radius: 10px">
<h2>Edit Penerbangan</h2>
<?= $msg ?>
<form method="post" action="edit_penerbangan.php?id=<?= $_GET['id'] ?>&edit=true">
<!-- Dropdown for Maskapai -->
<div class="mb-3">
<label for="maskapai" class="form-label">Maskapai</label>
<select class="form-select" id="maskapai" name="maskapai" required>
<option value="ryan_air" <?= $f["maskapai"] == 'ryan_air' ? 'selected' :'' ?>>Ryan Air</option>
<option value="batik_air" <?= $f["maskapai"] == 'batik_air' ? 'selected' :'' ?>>Batik Air</option>
<option value="easyjet" <?= $f["maskapai"] == 'easyjet' ? 'selected' :'' ?>>EasyJet</option>
</select>
</div>
<!-- Date input for Tanggal Penerbangan -->
<div class="mb-3">
<label for="tanggal_penerbangan" class="form-label">Tanggal Penerbangan</label>
<input type="date" class="form-control" id="tanggal_penerbangan" name="tanggal_penerbangan" value="<?= $f["tanggal_penerbangan"] ?>" required>
</div>
<!-- Number input for Kuota -->
<div class="mb-3">
<label for="kuota" class="form-label">Kuota</label>
<input type="number" class="form-control" id="kuota" name="kuota" value="<?= $f["kuota"] ?>" required>
</div>
<!-- Time input for Jam Kedatangan -->
<div class="mb-3">
<label for="jam_kedatangan" class="form-label">Jam Kedatangan</label>
<input type="time" class="form-control" id="jam_kedatangan" name="jam_kedatangan" value="<?= $f["jam_kedatangan"] ?>" required>
</div>
<!-- Text input for bandara asal -->
<div class="mb-3">
<label for="tujuan_akhir" class="form-label">Bandara Asal</label>
<input type="text" class="form-control" id="bandara_asal" value=" <?= $f["bandara_asal"] ?>" name="bandara_asal" required>
</div>
<!-- Text input for Tujuan Akhir -->
<div class="mb-3">
<label for="tujuan_akhir" class="form-label">Tujuan</label>
<input type="text" class="form-control" id="tujuan_akhir" name="tujuan_akhir" value=" <?= $f["tujuan_akhir"] ?>" required>
</div>
<!-- Text input for Sektor -->
<div class="mb-3">
<label for="sektor" class="form-label">Sektor</label>
<input type="text" class="form-control" id="sektor" name="sektor" value=" <?= $f["sektor"] ?>" required>
</div>
<!-- Number input for Harga -->
<div class="mb-3">
<label for="harga" class="form-label">Harga</label>
<input type="number" class="form-control" id="harga" name="harga" value= <?= strval($f["harga"]) ?> required>
</div>
<!-- Time input for Jam Berangkat -->
<div class="mb-3">
<label for="jam_berangkat" class="form-label">Jam Berangkat</label>
<input type="time" class="form-control" id="jam_berangkat" name="jam_berangkat" value="<?= $f["jam_berangkat"] ?>"required>
</div>
<!-- Time input for Jam Tiba -->
<div class="mb-3">
<label for="jam_tiba" class="form-label">Jam Tiba</label>
<input type="time" class="form-control" id="jam_tiba" name="jam_tiba" value="<?= $f["jam_tiba"] ?>" required>
</div>
<!-- Submit button -->
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
<script src="./../styles/bootstrap.bundle.min.js"></script>
</body>
</html>
Tampilan User
Login
Register
Index
Tampilan Petugas
Index
Tampilan User
Tambah Penerbangan
Data Penerbebangan
Komentar
Posting Komentar