<?php
session_start();
require "../Auth/db.php";

if (empty($_SESSION["user"]["is_admin"])) {
    header("Location: ../Index.php");
    exit;
}

$id = $_GET["id"] ?? null;

if (!$id) {
    header("Location: Dashboard.php?page=db_tvshows");
    exit;
}

$stmt = $pdo->prepare("DELETE FROM series_episodes WHERE series_id = ?");
$stmt->execute([$id]);

$stmt = $pdo->prepare("DELETE FROM media_series WHERE id = ?");
$stmt->execute([$id]);

header("Location: Dashboard.php?page=db_tvshows");
exit;