Files
trimape_web/blog/admin/delete.php
T
2026-07-15 19:45:08 -06:00

24 lines
598 B
PHP

<?php
require_once __DIR__ . '/auth.php';
requireLogin();
$db = getDB();
$postId = intval($_GET['id'] ?? 0);
if ($postId > 0) {
// Verify post exists
$stmt = $db->prepare("SELECT id, cover_image FROM blog_posts WHERE id = :id LIMIT 1");
$stmt->execute([':id' => $postId]);
$post = $stmt->fetch();
if ($post) {
// Delete post
$stmt = $db->prepare("DELETE FROM blog_posts WHERE id = :id");
$stmt->execute([':id' => $postId]);
$_SESSION['flash'] = 'Artículo eliminado correctamente.';
}
}
header('Location: ' . BLOG_URL . '/admin/');
exit;