-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdelete_user.php
More file actions
31 lines (27 loc) · 826 Bytes
/
delete_user.php
File metadata and controls
31 lines (27 loc) · 826 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
<?php
// Include database connection
include 'connection.php';
if (isset($_GET['user_id'])) {
$user_id = intval($_GET['user_id']);
$query = "DELETE FROM login WHERE id = ?";
$stmt = mysqli_prepare($connection, $query);
mysqli_stmt_bind_param($stmt, 'i', $user_id);
if (mysqli_stmt_execute($stmt)) {
echo "<script>
alert('User deleted successfully!');
window.location.href = 'manage_user.php';
</script>";
} else {
echo "<script>
alert('Error deleting user: " . mysqli_error($connection) . "');
window.location.href = 'manage_user.php';
</script>";
}
mysqli_stmt_close($stmt);
} else {
echo "<script>
alert('Invalid user ID.');
window.location.href = 'manage_user.php';
</script>";
}
?>