$studID = $_SESSION["studID"]; //The student's ID //Get the fake session variables that were stored as post variables $appTime = $_POST["appTime"]; $advisor = $_POST["advisor"]; //pull what used to be session variables $sql = "select * from Proj2Students where `StudentID` = '{$studID}'"; $rs = $COMMON->executeQuery($sql, $_SERVER["SCRIPT_NAME"]); $row = mysql_fetch_row($rs); $firstN = $row[1]; $lastN = $row[2]; $email = $row[4]; $major = $row[5]; $status = $row[6]; //Check that the appointment still exists if (!isStillAvailable($appTime, $advisor)) { $redirect = "13StudDenied.php"; } else { //regular new schedule if ($_POST["finish"] == 'Submit') { if ($advisor == 'Group') { $sql = "select * from Proj2Appointments where `Time` = '{$appTime}' and `AdvisorID` = 0"; $rs = $COMMON->executeQuery($sql, $_SERVER["SCRIPT_NAME"]); $row = mysql_fetch_row($rs); $groupids = $row[4]; $sql = "update `Proj2Appointments` set `EnrolledNum` = EnrolledNum+1, `EnrolledID` = '{$groupids} {$studID}' where `Time` = '{$appTime}' and `AdvisorID` = 0"; $rs = $COMMON->executeQuery($sql, $_SERVER["SCRIPT_NAME"]); $redirect = "12StudExit.php"; } else { $sql = "update `Proj2Appointments` set `EnrolledNum` = EnrolledNum+1, `EnrolledID` = '{$studID}' where `AdvisorID` = '{$advisor}' and `Time` = '{$appTime}'"; $rs = $COMMON->executeQuery($sql, $_SERVER["SCRIPT_NAME"]);
$email = $_SESSION["email"]; $advisor = $_SESSION["advisor"]; //If debugging, show what the advisor is if ($debug) { echo "Advisor -> {$advisor}<br>\n"; } $apptime = $_SESSION["appTime"]; //If the student doesn't already exist in student DB, add him/her to that DB if ($_SESSION["studExist"] == false) { $sql = "insert into Proj2Students (`FirstName`,`LastName`,`StudentID`,`Email`,`Major`) values ('{$firstn}','{$lastn}','{$studid}','{$email}','{$major}')"; $rs = $COMMON->executeQuery($sql, $_SERVER["SCRIPT_NAME"]); } // ************************ Lupoli 9-1-2015 // we have to check to make sure someone did not steal that spot just before them!! (deadlock) // if the spot was taken, need to stop and reset if (isStillAvailable($apptime, $advisor)) { } else { if ($debug == false) { //Push user to 13StudDenied.php, denied page header('Location: 13StudDenied.php'); return; } } //regular new schedule, if was a new appointment scheduling if ($_POST["finish"] == 'Submit') { if ($_SESSION["advisor"] == 'Group') { //Get the app at the requested time $sql = "select * from Proj2Appointments where `Time` = '{$apptime}' and `AdvisorID` = 0"; $rs = $COMMON->executeQuery($sql, $_SERVER["SCRIPT_NAME"]); $row = mysql_fetch_row($rs); $groupids = $row[4];
} else { // Get student info from database $studid = $_SESSION["studID"]; $student = new Student($COMMON, $studid); // Get new appointment info from database $newApptID = $_POST['appID']; $newAppt = new Appointment($COMMON, $newApptID); // Get new advisor ID $advisorID = $newAppt->getAdvisorID(); if ($debug) { echo "Advisor -> {$advisorID}<br>\n"; } // ************************ Lupoli 9-1-2015 // we have to check to make sure someone did not steal that spot just before them!! (deadlock) // if the spot was taken, need to stop and reset if (isStillAvailable($_POST['appID'])) { } else { if ($debug == false) { header('Location: 13StudDenied.php'); return; } } if ($_POST["finish"] == 'Reschedule') { // Get info from database about old appointment $oldApptID = $_POST["oldAppID"]; $oldAppt = new Appointment($COMMON, $oldApptID); //remove stud from EnrolledID $newIDs = str_replace($studid, "", $oldAppt->getEnrolledID()); if ($debug) { echo "Old IDs: " . $oldAppt->getEnrolledID() . "<br>"; echo "New IDs: {$newIDs}<br>";