<?php require __DIR__ . '/../app/init.php'; $general->loggedOutProtect(); // redirect if user elevation is not that of secretary or admin if ($user->isTutor()) { header('Location: ' . BASE_URL . "error-403"); exit; } $pageTitle = "Academia - Students"; $section = "academia"; try { $students = StudentFetcher::retrieveAll(); $majors = MajorFetcher::retrieveMajors(); $appointments = AppointmentFetcher::retrievePendingForAllStudents(); if (isBtnAddStudentPrsd()) { $majorId = !empty($_POST['userMajorId']) ? $_POST['userMajorId'] : null; Student::create($_POST['firstName'], $_POST['lastName'], $_POST['email'], $_POST['studentId'], $_POST['mobileNum'], $majorId, $_POST['ciInput'], $_POST['creditsInput']); header('Location: ' . BASE_URL . "academia/students/success"); exit; } else { if (isBtnAddMajorPrsd()) { Major::create($_POST['majorCode'], $_POST['majorName']); header('Location: ' . BASE_URL . "academia/students/success"); } else { if (isBtnUpdatePrsd()) { if (!isset($_POST['idUpdate']) || ($oldStudentData = getStudent($_POST['idUpdate'], $students)) === false) { throw new Exception("Data tempering detected. Process stopped."); } else { $id = $oldStudentData[StudentFetcher::DB_COLUMN_ID]; $newFirstName = $_POST['newFirstName'];