Initial commit: Setup Landing Page dan file pertemuan
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Tolak akses jika bukan admin
|
||||
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
|
||||
http_response_code(403); // Status Forbidden
|
||||
echo "Akses ditolak! Anda bukan operator.";
|
||||
exit;
|
||||
}
|
||||
|
||||
include 'koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$id = $_POST['id'];
|
||||
$tabel = $_POST['tabel'];
|
||||
|
||||
// Daftar tabel yang diizinkan (untuk keamanan)
|
||||
$allowed_tables = ['spbu_locations', 'jalan', 'parsil', 'rumah_ibadah', 'penduduk_miskin'];
|
||||
|
||||
if (in_array($tabel, $allowed_tables)) {
|
||||
$stmt = $conn->prepare("DELETE FROM $tabel WHERE id = ?");
|
||||
$stmt->bind_param("i", $id); // "i" karena ID sekarang adalah Integer
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo "Data berhasil dihapus!";
|
||||
} else {
|
||||
echo "Gagal menghapus: " . $conn->error;
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo "Tabel tidak valid!";
|
||||
}
|
||||
$conn->close();
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user