<?php
session_start();
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header('Location: index.php');
    exit;
}
require 'dbconn.php';

if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = intval($_GET['id']);

    // Delete video record from the table
    $stmt = $mysqli->prepare("DELETE FROM videos WHERE id = ?");
    $stmt->bind_param("i", $id);

    if ($stmt->execute()) {
        header("Location: manage_videos.php?status=deleted");
        exit;
    } else {
        echo "Error deleting video: " . $stmt->error;
    }

} else {
    echo "Invalid video ID.";
}
?>
