26 lines
615 B
PHP
26 lines
615 B
PHP
<?php
|
|
session_start();
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
// If the user is not logged in or not an admin, redirect them.
|
|
if (!isset($_SESSION['user_id']) || !$_SESSION['is_admin']) {
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
$video_id = $_GET['id'] ?? null;
|
|
|
|
if ($video_id) {
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("DELETE FROM videos WHERE id = ?");
|
|
$stmt->execute([$video_id]);
|
|
} catch (PDOException $e) {
|
|
// You might want to log this error instead of dying
|
|
die("Database error: " . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
header("Location: admin.php");
|
|
exit;
|