<?php
session_start();

if (!isset($_SESSION['login'])) {
    header('location:login');
    exit;
}

require 'function.php';

if (isset($_GET['no_id'])) {
    $no_id = (int)$_GET['no_id'];
    
    if (hapus($no_id) > 0) {
        header('location:dashboard');
        exit;
    } else {
        echo "<script>alert('Gagal menghapus data tamu'); document.location.href = 'dashboard';</script>";
        exit;
    }
}

if (isset($_GET['id'])) {
    $id = (int)$_GET['id'];
    
    if (hapuscat($id) > 0) {
        header('location:event');
        exit;
    } else {
        echo "<script>alert('Gagal menghapus kategori'); document.location.href = 'event';</script>";
        exit;
    }
}

header('location:dashboard');
exit;
