You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
633 B
30 lines
633 B
6 months ago
|
<?php
|
||
|
require 'db_connection.php';
|
||
|
session_start();
|
||
|
|
||
|
// Check if admin is logged in
|
||
|
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'admin') {
|
||
|
header("Location: login.php");
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
// Check if the user ID is provided
|
||
|
if (isset($_GET['id'])) {
|
||
|
$user_id = intval($_GET['id']);
|
||
|
|
||
|
// Delete user
|
||
|
$stmt = $conn->prepare("DELETE FROM users WHERE id = ?");
|
||
|
$stmt->bind_param("i", $user_id);
|
||
|
|
||
|
if ($stmt->execute()) {
|
||
|
header("Location: admin_dashboard.php");
|
||
|
exit;
|
||
|
} else {
|
||
|
echo "Error deleting user.";
|
||
|
}
|
||
|
} else {
|
||
|
header("Location: admin_dashboard.php");
|
||
|
exit;
|
||
|
}
|
||
|
?>
|