<?php
require_once "includes/auth.php";
require_once "includes/db.php";

$userId = $_SESSION["user_id"];

if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["course_id"])) {
    $courseId = (int) $_POST["course_id"];
    $stmt = $conn->prepare("DELETE FROM enrollments WHERE user_id = ? AND course_id = ?");
    $stmt->execute([$userId, $courseId]);
}

header("Location: dashboard.php");
exit;
