<?php
include('includes/dbconnection.php');
include('includes/flash.php');

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

    // Prepare delete query
    $stmt = $con->prepare("DELETE FROM events WHERE id = ?");
    $stmt->bind_param("i", $event_id);

    if ($stmt->execute()) {
        flash_alert('Event Deleted Successfully!', 'add_event.php');
        header('Location: add_event.php'); exit;
    } else {
        flash_alert('Something went wrong. Please try again.');
    }

    $stmt->close();
}
?>
