Upload New File

parent 5cca4257
<?php
session_start();
include('../config.php');
include('function.php');
// include("../common/dbconfig.php");
include("template/header.php");
include("../common/function.php");
open_page("Destinasi");
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 destinasi";
$data = mysqli_query($koneksi,$query);
if(isset($_POST["tambah"]))
{
if(tambahdestinasi($_POST) > 0 )
{
echo
"
<script>
alert('Berhasil ditambahkan');
document.location.href = 'destinasi_admin.php';
</script>
";
} else {
echo
"
<script>
alert('Gagal ditambahkan');
document.location.href = 'destinasi_admin.php';
</script>
";
}
}
?>
<!-- ======= Breadcrumbs ======= -->
<section id="breadcrumbs" class="breadcrumbs">
<div class="container">
<div class="d-flex justify-content-between align-items-center">
<h2>Destinasi</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" rowspan="2">Nama Destinasi</th>
<th scope="col" rowspan="2">Pulau</th>
<th scope="col" rowspan="2">Provinsi</th>
<th scope="col" rowspan="2">Deskripsi</th>
<th scope="col" rowspan="2">Gambar</th>
<th scope="col">Option</th>
</tr>
</thead>
<?php while($destinasi = mysqli_fetch_array($data)) { ?>
<tr>
<td align="center"><?= $destinasi['nama_destinasi'] ?></td>
<td align="center"><?= $destinasi['pulau'] ?></td>
<td align="center"><?= $destinasi['provinsi'] ?></td>
<td><?= $destinasi['deskripsi_destinasi'] ?></td>
<td><img src="<?= BASEURL; ?>public/img/<?= $destinasi['gambar_destinasi'] ?>" class="align-self-center mr-5 mt-3" alt="gambar_destinasi" style="width:150px;length:150px"></td>
<td>
<a href="ubahdestinasi.php?id_destinasi=<?= $destinasi['id_destinasi'];?>" class="badge badge-success">Ubah</a>
<a href="hapusdestinasi.php?id_destinasi=<?= $destinasi['id_destinasi'];?>" onclick="return confirm('Apakah Anda sudah yakin ?');" class="badge badge-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">
<h2>Tambah Destinasi</h2>
<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">
<form action="" method="POST" enctype="multipart/form-data">
</div>
<form>
<div class="form-group">
<label for="nama_destinasi">Nama Destinasi</label>
<input autocomplete="off" type="text" name="nama_destinasi" class="form-control" placeholder="Masukkan nama destinasi">
</div>
<div class="form-group">
<label for="pulau">Pulau</label>
<input autocomplete="off" type="text" name="pulau" class="form-control" placeholder="Masukkan nama destinasi">
</div>
<div class="form-group">
<label for="provinsi">Provinsi</label>
<select class="form-control" name="provinsi">
<option value="Aceh">Aceh</option>
<option value="Sumatera Utara">Sumatera Utara</option>
<option value="Sumatera Barat">Sumatera Barat</option>
<option value="Riau">Riau</option>
<option value="Kepulauan Riau">Kepulauan Riau</option>
<option value="Jambi">Jambi</option>
<option value="Bengkulu">Bengkulu</option>
<option value="Sumatera Selatan">Sumatera Selatan</option>
<option value="Kepulauan Bangka Belitung">Kepulauan Bangka Belitung</option>
<option value="Lampung">Lampung</option>
<option value="Banteng">Banteng</option>
<option value="Jawa Barat">Jawa Barat</option>
<option value="DKI Jakarta">DKI Jakarta</option>
<option value="Jawa Tengah">Jawa Tengah</option>
<option value="DI Yogyakarta">DI Yogyakarta</option>
<option value="Jawa Timur">Jawa Timur</option>
<option value="Bali">Bali</option>
<option value="Nusa Tenggara Barat">Nusa Tenggara Barat</option>
<option value="Nusa Tenggara Timur">Nusa Tenggara Timur</option>
<option value="Kalimantan Utara">Kalimantan Utara</option>
<option value="Kalimantan Barat">Kalimantan Barat</option>
<option value="Kalimantan Tengah">Kalimantan Tengah</option>
<option value="Kalimantan Selatan">Kalimantan Selatan</option>
<option value="Kalimantan Timur">Kalimantan Timur</option>
<option value="Gorontalo">Gorontalo</option>
<option value="Sulawesi Utara">Sulawesi Utara</option>
<option value="Sulawesi Barat">Sulawesi Barat</option>
<option value="Sulawesi Tengah">Sulawesi Tengah</option>
<option value="Sulawesi Selatan">Sulawesi Selatan</option>
<option value="Sulawesi Tenggara">Sulawesi Tenggara</option>
<option value="Maluku Utara">Maluku Utara</option>
<option value="Maluku">Maluku</option>
<option value="Papua Barat">Papua Barat</option>
<option value="Papua">Papua</option>
</select>
</div>
<div class="form-group">
<label for="deskripsi_destinasi">Deskripsi Destinasi</label>
<input autocomplete="off" type="text" name="deskripsi_destinasi" class="form-control" placeholder="Masukkan nama destinasi">
</div>
<div class="form-group">
<label for="gambar_destinasi">Gambar Destinasi</label>
<input autocomplete="off" type="file" class="form-control" name="gambar_destinasi">
</div>
<button type="submit" class="btn btn-primary" name="tambah">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