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

if ($_SESSION['role'] != 'admin') {
    die("Akses ditolak");
}

$id = $_GET['id'];

/*
Karena sudah ON DELETE CASCADE,
data absensi otomatis ikut terhapus
*/
mysqli_query($conn, "DELETE FROM users WHERE id='$id'");

echo "<script>
    alert('User dan seluruh data absensi berhasil dihapus');
    window.location='data_user.php';
</script>";
?>