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.
 
 
 
 
FutureCraft/delete_user.php

29 lines
633 B

<?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;
}
?>