<?php
declare(strict_types=1);
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/../includes/functions.php';
require_once __DIR__ . '/../includes/student-auth.php';
require_once __DIR__ . '/../includes/student-course-context.php';
$pdo=db(); requireStudent();
$studentId=(int)currentStudentId();
$courseId=(int)($_POST['course_id'] ?? $_GET['course_id'] ?? 0);
if ($courseId>0 && isStudentEnrolledInCourse($pdo,$studentId,$courseId)) {
    setSelectedStudentCourse($courseId);
    redirect('student/dashboard.php?course_id='.$courseId);
}
flash('error','Invalid or unavailable course.');
redirect('student/my-courses.php');
