-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_menu.php
More file actions
40 lines (32 loc) · 947 Bytes
/
delete_menu.php
File metadata and controls
40 lines (32 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
session_start();
// cek apakah yang mengakses halaman ini sudah login
if ($_SESSION['level'] == "") {
header("location:login.php?pesan=gagal");
}
?>
<?php
include('koneksi.php');
// Check if ID parameter is set
if (isset($_GET['id'])) {
$menuId = $_GET['id'];
// Delete menu from the database
$deleteQuery = "DELETE FROM menus WHERE no_menu = ?";
$deleteStmt = $koneksi->prepare($deleteQuery);
if ($deleteStmt) {
$deleteStmt->bind_param("i", $menuId);
$deleteStmt->execute();
$deleteStmt->close();
// Redirect to add_menu.php or any other desired page after successful delete
header("location: add_menu.php?success=3");
exit;
} else {
echo "Error preparing statement: " . $koneksi->error;
}
} else {
// Redirect if ID parameter is not set
header("location: add_menu.php");
exit;
}
// Close the database connection
$koneksi->close();