<?php
session_start();
require_once "../config/db.php";

if (!isset($_SESSION['admin_id'])) {
    header("Location: login.php");
    exit();
}

if (isset($_GET['id'])) {
    $id = (int)$_GET['id'];
    
    // Soft delete user query
    $delete_query = "UPDATE users SET is_deleted = 1 WHERE id = $id";
    
    if (mysqli_query($conn, $delete_query)) {
        header("Location: manage-users.php?msg=User deleted successfully&msg_type=success");
    } else {
        header("Location: manage-users.php?msg=Error deleting user: " . mysqli_error($conn) . "&msg_type=danger");
    }
} else {
    header("Location: manage-users.php");
}
exit();
?>
