0) { $select_row = mysqli_fetch_assoc($select_result); $image_name = $select_row['v_video']; $image_path = "videos/" . $image_name; // Delete the image file if it exists if (file_exists($image_path)) { unlink($image_path); } // Delete the record from the database $delete_gallery = "DELETE FROM video WHERE v_id = $g_id"; $delete_result = mysqli_query($con, $delete_gallery); if ($delete_result) { $_SESSION['gallery_delete'] = "Video deleted successfully!"; } else { $_SESSION['gallery_delete'] = "Video delete failed!"; } } else { $_SESSION['gallery_delete'] = "Video not found!"; } header('Location: video.php'); exit; } else { header('Location: video.php'); exit; } ?>