<?php
declare(strict_types=1);
session_start();
require_once '../../config.php';
if (!isset($_SESSION['user_id'])) { http_response_code(401); echo json_encode(['success'=>false]); exit; }
header('Content-Type: application/json');
$conn = getDBConnection();
$id = (int) ($_POST['id'] ?? 0);
if (!$conn instanceof mysqli || $id <= 0) { echo json_encode(['success'=>false,'message'=>'Invalid request']); exit; }
$stmt = $conn->prepare("DELETE FROM exam_papers WHERE id = ?");
$stmt->bind_param('i', $id);
$stmt->execute();
$stmt->close();
echo json_encode(['success'=>true,'message'=>'Paper deleted successfully']);
