prepare("INSERT INTO leave_requests (student_id, leave_type, start_date, end_date, reason, attachment_path) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->execute([$student_id, $leave_type, $start_date, $end_date, $reason, $attachment_path]); // Send email to teacher $teacher_email = 'teacher@example.com'; // Hardcoded for now $subject = 'New Leave Request from ' . $_SESSION['user_full_name']; $body = "

A new leave request has been submitted by {" . $_SESSION['user_full_name'] . "}.

\n

Leave Type: {" . $leave_type . "}

\n

Start Date: {" . $start_date . "}

\n

End Date: {" . $end_date . "}

\n

Reason: {" . $reason . "}

\n

Please login to the dashboard to approve or reject this request.

"; MailService::sendMail($teacher_email, $subject, $body); header('Location: student_dashboard.php?success=1'); exit; } catch (PDOException $e) { die('Database error: ' . $e->getMessage()); } }