blog+contacto php listo
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?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;
|
||||
?>
|
||||
Reference in New Issue
Block a user