<?php
session_start();
require ("../dbconnect.php");

// Check if the user is logged in as an admin
if (!isset($_SESSION['ADMIN_LOGIN']) || $_SESSION['ADMIN_LOGIN'] != 'yes') {
    header("location: index.php");
    exit;
}

// Get the access ID from the URL
if (isset($_GET['id'])) {
    $access_id = mysqli_real_escape_string($con, $_GET['id']);
    
    // Delete the video access from the database
    $query = "DELETE FROM user_video_access WHERE id = '$access_id'";
    if (mysqli_query($con, $query)) {
        echo "<script>alert('Video access revoked successfully.'); window.location.href='manage_video_access.php';</script>";
    } else {
        echo "<script>alert('Error revoking video access.'); window.location.href='manage_video_access.php';</script>";
    }
} else {
    header("location: manage_video_access.php");
    exit;
}
?>
