<?php
session_start();
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header('Location: index.php');
    exit;
}
require 'dbconn.php';
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

try {
    if (isset($_GET['id'])) {
        $id = intval($_GET['id']);

        $stmt = $mysqli->prepare("DELETE FROM members WHERE id = ?");
        $stmt->bind_param("i", $id);
        $stmt->execute();

        header("Location: manage_members.php?deleted=1");
        exit;
    } else {
        echo "Invalid request.";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
