<?php
require 'config.php';
session_start();

$teacher_id = $_SESSION['teacher_id'] ?? null;
if (!$teacher_id) {
    echo "Unauthorized.";
    exit;
}

$id = $_POST['id'] ?? null;
if(!$id){ echo "Invalid request."; exit; }

$stmt = $dbh->prepare("DELETE FROM questions WHERE id=:id AND teacher_id=:teacher_id");
if($stmt->execute([':id'=>$id, ':teacher_id'=>$teacher_id])){
    echo "Question deleted.";
} else {
    echo "Error deleting question.";
}
