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

if (isset($_GET['id'])) {
    $id = intval($_GET['id']);
    $query = "DELETE FROM tb_pengumuman WHERE id_pengumuman = $id";
    if (mysqli_query($host, $query)) {
        echo "<script>alert('Pengumuman berhasil dihapus!'); window.location.href='manage_pengumuman.php';</script>";
    } else {
        echo "<script>alert('Error: " . mysqli_error($host) . "');</script>";
    }
} else {
    echo "<script>alert('ID pengumuman tidak ditemukan!'); window.location.href='manage_pengumuman.php';</script>";
}
?>

