<?php 
    require_once('connection.php');

    if(!isset($_GET['id'])){
        echo "<script> alert('Undefined Schedule ID.'); location.replace('./') </script>";
        $conn->close();
        exit;
    }

    $delete = $conn->query("DELETE FROM `calendar_event_master` where id = '{$_GET['id']}'");

    if($delete){
        echo "<script> alert('Event has deleted successfully.'); location.replace('./') </script>";
        header("Location: add_event.php?success=Event has deleted successfully.");

    }else{
        header("Location: add_event.php?error=An Error occurred.");

    }
    
    $conn->close();
?>