-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiamond_delete.php
More file actions
36 lines (31 loc) · 896 Bytes
/
diamond_delete.php
File metadata and controls
36 lines (31 loc) · 896 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
<?php
// diamond_delete.php
include 'config.php';
// Check if user is logged in
if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true) {
header("location: index.php");
exit;
}
// Check if ID parameter is set
if (isset($_GET["id"]) && !empty(trim($_GET["id"]))) {
// Prepare a delete statement
$sql = "DELETE FROM diamonds WHERE id = ?";
if ($stmt = $conn->prepare($sql)) {
$stmt->bind_param("i", $param_id);
$param_id = trim($_GET["id"]);
if ($stmt->execute()) {
// Redirect to landing page on success
header("location: diamond_master.php");
exit();
} else {
echo "Oops! Something went wrong. Please try again later.";
}
}
$stmt->close();
$conn->close();
} else {
// Redirect if ID is missing
header("location: diamond_master.php");
exit();
}
?>