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'] . "}.
\nLeave Type: {" . $leave_type . "}
\nStart Date: {" . $start_date . "}
\nEnd Date: {" . $end_date . "}
\nReason: {" . $reason . "}
\nPlease 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()); } }