<?php
require_once 'db.php';

if (!isset($_SESSION['user_id'])) {
    header("Location: login.php");
    exit;
}

$id = $_GET['id'] ?? 0;
$instansi_id = $_SESSION['instansi_id'];

if ($id > 0) {
    $stmt = $pdo->prepare("DELETE FROM berita WHERE id = ? AND instansi_id = ?");
    $stmt->execute([$id, $instansi_id]);
}

// Redirect kembali ke halaman sebelumnya
$ref = $_SERVER['HTTP_REFERER'] ?? 'pro.php';
header("Location: " . $ref);
exit;
