-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_delete.php
138 lines (128 loc) · 5.41 KB
/
admin_delete.php
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
session_start();
if (isset($_SESSION['email']) && isset($_SESSION['username']) && isset($_SESSION['password'])) {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="images/layout/logo_new.png" type="image/x-icon">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js"></script>
</head>
<body>
<?php
require "conn.php";
if (isset($_GET['reportID'])) {
$id = $_GET['reportID'];
$sql = "DELETE FROM report WHERE reportID = $id";
if ($conn->query($sql) === TRUE) {
echo '<script>
swal({
title: "Success",
text: "Report deleted successfully!",
icon: "success",
timer: 2000,
timerProgressBar: true,
onClose: () => {
window.location.href = "admin_mng_reports.php";
}
});
</script>';
} else {
echo '<script>
swal({
title: "Error",
text: "Error deleting report: ' . $conn->error . '",
icon: "error"
});
</script>';
}
} elseif (isset($_GET['citizenID'])) {
$id = $_GET['citizenID'];
$sql = "DELETE FROM citizens WHERE citizenID = $id";
if ($conn->query($sql) === TRUE) {
echo '<script>
swal({
title: "Success",
text: "Citizen deleted successfully!",
icon: "success",
timer: 2000,
timerProgressBar: true,
onClose: () => {
window.location.href = "admin_mng_citizens.php";
}
});
</script>';
} else {
echo '<script>
swal({
title: "Error",
text: "Error deleting citizen: ' . $conn->error . '",
icon: "error"
});
</script>';
}
} elseif (isset($_GET['policeID'])) {
$id = $_GET['policeID'];
$sql = "DELETE FROM police WHERE policeID = $id";
if ($conn->query($sql) === TRUE) {
echo '<script>
swal({
title: "Success",
text: "Police deleted successfully!",
icon: "success",
timer: 2000,
timerProgressBar: true,
onClose: () => {
window.location.href = "admin_mng_police.php";
}
});
</script>';
} else {
echo '<script>
swal({
title: "Error",
text: "Error deleting police: ' . $conn->error . '",
icon: "error"
});
</script>';
}
} elseif (isset($_GET['crime_id'])) {
$id = $_GET['crimeID'];
$sql = "DELETE FROM type_crimes WHERE crime_id = $id";
if ($conn->query($sql) === TRUE) {
echo '<script>
swal({
title: "Success",
text: "Crime deleted successfully!",
icon: "success",
timer: 2000,
timerProgressBar: true,
onClose: () => {
window.location.href = "admin_mng_crime.php";
}
});
</script>';
} else {
echo '<script>
swal({
title: "Error",
text: "Error deleting crime: ' . $conn->error . '",
icon: "error"
});
</script>';
}
}
?>
</body>
<?php
} else {
header("Location:invalid.php");
}
?>