Upload New File

parent 6e37d78d
<?php
session_start();
include('../config.php');
include('function.php');
// include("../common/dbconfig.php");
include("template/header.php");
include("../common/function.php");
open_page("Kategori");
if(! isset($_SESSION['is_login']))
{
header('location:../index.php');
}
if (!isset($_SESSION["username"])){
// echo "<script>alert('Login terlebih dahulu');window.location='../index.php';</script>";
// exit;
echo "Anda harus login dulu <br><a href='../index.php'>Klik disini</a>";
exit;
}
$role = $_SESSION["role"];
if($role != "admin"){
echo "<script>alert('Anda bukan admin');window.location='../index.php';</script>";
exit;
}
$id_akun = $_SESSION["id_akun"];
$nama = $_SESSION["nama"];
$username = $_SESSION["username"];
$query = "SELECT * FROM pt_kategori";
$data = mysqli_query($koneksi,$query);
if(isset($_POST["daftar"]))
{
if(tambahkategori($_POST) > 0 )
{
echo
"
<script>
alert('Berhasil ditambahkan');
document.location.href = 'kategori_admin.php';
</script>
";
} else {
echo
"
<script>
alert('Gagal ditambahkan');
document.location.href = 'kategori_admin.php';
</script>
";
}
}
?>
<!-- ======= Breadcrumbs ======= -->
<section id="breadcrumbs" class="breadcrumbs">
<div class="container">
<div class="d-flex justify-content-between align-items-center">
<h2>Kategori</h2>
</div>
</div>
</section>
<!-- End Breadcrumbs -->
<div class="container">
<button type="button" class="btn btn-primary mt-3" data-toggle="modal" data-target="#exampleModal">
Tambah Data
</button>
<table class="table table-bordered mt-3 mb-2">
<thead class="thead-dark">
<tr align="center">
<th scope="col">Nama Kategori</th>
<th scope="col">Deskripsi</th>
<th scope="col">Option</th>
</tr>
</thead>
<?php
while($kategori = mysqli_fetch_array($data)) { ?>
<tr>
<td align="center"><?= $kategori['nama_kategori'] ?></td>
<td><?= $kategori['deskripsi'] ?></td>
<td>
<a href="ubahkategori.php?id_kategori=<?= $kategori['id_kategori'];?>" class="btn btn-success">Ubah</a> ||
<a href="hapuskategori.php?id_kategori=<?= $kategori['id_kategori'];?>" onclick="return confirm('Apakah Anda sudah yakin ?');" class="btn btn-danger">Hapus</a>
</td>
</tr>
<?php } ?>
</table>
<!-- Modal tambah-->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="container">
<h2>Tambah Kategori</h2>
<form action="" method="POST">
</div>
<form>
<div class="form-group">
<label for="nama_kategori">Nama Kategori</label>
<input type="text" name="nama_kategori" class="form-control" placeholder="Masukkan nama destinasi">
</div>
<div class="form-group">
<label for="deskripsi">Deskripsi</label>
<textarea rows="2" cols="20" name="deskripsi" class="form-control" placeholder="masukkan jumlah tiket">
</textarea>
</div>
<button type="submit" class="btn btn-primary" name="daftar">Tambah</button>
</form>
</div>
</div>
</div>
</div>
<!-- End Modal tambah-->
</div>
<?php
include("template/footer.php")
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment