<?php
session_start();
include 'config.php';

if (isset($_GET['id'])) {
    $userId = $_GET['id'];
    $query = "DELETE FROM users WHERE id = :id";
    $stmt = $db->prepare($query);
    $stmt->bindParam(':id', $userId, PDO::PARAM_INT);

    try {
        if ($stmt->execute()) {
            $_SESSION['message'] = "User deleted successfully.";
            $_SESSION['message_type'] = "success"; // Message type
        } else {
            $_SESSION['message'] = "Failed to delete user.";
            $_SESSION['message_type'] = "error";
        }
    } catch (PDOException $e) {
        $_SESSION['message'] = "Error: " . $e->getMessage();
        $_SESSION['message_type'] = "error";
    }
} else {
    $_SESSION['message'] = "User ID not found.";
    $_SESSION['message_type'] = "error";
}

header("Location: customer.php"); // Redirect to customer.php
exit;
