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

if (!isset($_GET['id'])) {
    header('Location: manage_admin.php');
    exit;
}

$id = $_GET['id'];

// Cegah admin menghapus dirinya sendiri
if ($id == $_SESSION['admin_id']) {
    echo "Tidak bisa menghapus akun yang sedang login.";
    exit;
}

$stmt = $db->prepare("DELETE FROM admin_users WHERE id = ?");
$stmt->execute([$id]);

header('Location: manage_admin.php');
exit;
