File "delete_store_videos.php"
Full Path: /home/ccipcixf/public_html/pmi/dashboard/delete_store_videos.php
File size: 1.71 KB
MIME-type: text/x-php
Charset: utf-8
<?php
include 'config.php';
// Check if ID is provided
if (isset($_POST['id'])) {
$id = intval($_POST['id']); // Sanitize input
// Step 1: Retrieve the video path from the database
$query = "SELECT video_path FROM `zyn_store_videos` WHERE id = $id";
$result = mysqli_query($conn, $query);
if ($result && mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$videoPath = $row['video_path'];
$path = '../campaign/' . $videoPath;
// echo $path;
// exit;
// Step 2: Delete the video file from the server
if (file_exists($path)) {
if (unlink($path)) {
// Step 3: Delete the record from the database
$deleteQuery = "DELETE FROM `zyn_store_videos` WHERE id = $id";
if (mysqli_query($conn, $deleteQuery)) {
header("Location: admin_store_videos.php?success=Video deleted successfully");
exit();
} else {
header("Location: admin_store_videos.php?error=Failed to delete video record from database");
exit();
}
} else {
header("Location: admin_store_videos.php?error=Failed to delete video file from server");
exit();
}
} else {
header("Location: admin_store_videos.php?error=Video file not found on server");
exit();
}
} else {
header("Location: admin_store_videos.php?error=Video record not found in database");
exit();
}
} else {
header("Location: admin_store_videos.php?error=Invalid request");
exit();
}
?>