<?php
include "config.php"; // Ensure this connects to your DB

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($_POST['id'])) {
        $id = mysqli_real_escape_string($con, $_POST['id']);

        $deleteQuery = "DELETE FROM notice WHERE id = '$id'";

        if (mysqli_query($con, $deleteQuery)) {
               echo '<script>window.location.href = "notice.php";</script>';
          
        } else {
            echo "Error deleting notice: " . mysqli_error($con);
        }
    } else {
        echo "Invalid request: ID missing.";
    }
} else {
    echo "Invalid request method.";
}
?>