<?php
require_once __DIR__ . '/admin_auth.php';
require_once __DIR__ . '/../includes/db.php';

header('Content-Type: application/json');

$id = (int)($_GET['id'] ?? 0);

if ($id <= 0) {
    echo json_encode(['status'=>'error', 'message'=>'Invalid user ID.']);
    exit;
}

$stmt = $pdo->prepare("DELETE FROM users WHERE id = ?");
if ($stmt->execute([$id])) {
    echo json_encode(['status'=>'success', 'message'=>'User deleted successfully.']);
} else {
    echo json_encode(['status'=>'error', 'message'=>'Unable to delete user.']);
}
?>
