<?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_post WHERE id_post = $id";
    if (mysqli_query($host, $query)) {
        echo "<script>alert('Berita berhasil dihapus!'); window.location.href='berita_admin.php';</script>";
    } else {
        echo "<script>alert('Error: " . mysqli_error($host) . "');</script>";
    }
} else {
    echo "<script>alert('ID berita tidak ditemukan!'); window.location.href='berita_admin.php';</script>";
}
?>

