40097-vm/delete_marketing_video.php
2026-05-18 19:22:27 +00:00

24 lines
676 B
PHP

<?php
include 'db/config.php';
$db = db();
if (isset($_GET['id'])) {
$id = $_GET['id'];
// Obtener la ruta de la foto para borrarla del servidor si existe
$stmt = $db->prepare("SELECT foto_producto FROM marketing_videos WHERE id = ?");
$stmt->execute([$id]);
$video = $stmt->fetch(PDO::FETCH_ASSOC);
if ($video) {
if (!empty($video['foto_producto']) && file_exists($video['foto_producto'])) {
unlink($video['foto_producto']);
}
$stmt = $db->prepare("DELETE FROM marketing_videos WHERE id = ?");
$stmt->execute([$id]);
}
}
header("Location: marketing_produccion.php?success=1");
exit;