36947-vm/delete.php
Flatlogic Bot 4be8924eba Educ8
2025-12-14 21:05:45 +00:00

25 lines
454 B
PHP

<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
require_once __DIR__ . '/db/config.php';
$post_id = $_GET['id'] ?? null;
if ($post_id) {
try {
$pdo = db();
$stmt = $pdo->prepare("DELETE FROM posts WHERE id = ?");
$stmt->execute([$post_id]);
} catch (PDOException $e) {
die("Error: " . $e->getMessage());
}
}
header('Location: admin.php');
exit;
?>