29 lines
646 B
PHP
29 lines
646 B
PHP
<?php
|
|
require_once '../config/db.php';
|
|
require_once 'auth.php';
|
|
verificarAuth();
|
|
|
|
if (!isset($_GET['id'])) {
|
|
header('Location: dashboard.php');
|
|
exit;
|
|
}
|
|
|
|
// Obtener el artículo para borrar la imagen
|
|
$stmt = $pdo->prepare("SELECT imagen FROM blog_posts WHERE id = ?");
|
|
$stmt->execute([$_GET['id']]);
|
|
$post = $stmt->fetch();
|
|
|
|
if ($post && $post['imagen']) {
|
|
$ruta_imagen = '../' . $post['imagen'];
|
|
if (file_exists($ruta_imagen)) {
|
|
unlink($ruta_imagen);
|
|
}
|
|
}
|
|
|
|
// Eliminar el artículo
|
|
$stmt = $pdo->prepare("DELETE FROM blog_posts WHERE id = ?");
|
|
$stmt->execute([$_GET['id']]);
|
|
|
|
header('Location: dashboard.php');
|
|
exit;
|
|
?>
|