<?php
session_start();
if (!isset($_SESSION['id_admin'])) {
    header('Location: login_admin.php');
    exit;
}

include 'includes/config.php';

$id = $_GET['id'] ?? null;
if (!$id) {
    echo "<script>alert('ID penyertaan tidak sah'); window.location='senarai_penyertaan.php';</script>";
    exit;
}

$sql = "DELETE FROM penyertaan WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $id);

if ($stmt->execute()) {
    echo "<script>alert('Penyertaan berjaya dipadam.'); window.location='senarai_penyertaan.php';</script>";
} else {
    echo "<script>alert('Ralat semasa memadam penyertaan.'); window.location='senarai_penyertaan.php';</script>";
}
