25 lines
725 B
PHP
25 lines
725 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]);
|
|
}
|
|
}
|
|
|
|
$redirect = $_GET['redirect'] ?? 'marketing_produccion.php?success=1';
|
|
header("Location: " . $redirect);
|
|
exit; |