2
////Checks if student is registered for a course occasion
3
////Parameters: loginName, password, courseName, semester (e.g. HT), year (e.g. 12), period (e.g. 1,2,3,4 or 5)
4
////Returns true if student login name is registered for selected course and correct password was given
6
//Prevents browsers (IE) from caching the response
7
header('Cache-Control: no-cache, must-revalidate');
8
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
9
header('Content-type: application/json; charset=utf-8');
11
include "dbconnect.php";
13
$queryString="SELECT COUNT(*)
14
FROM Student, StudentCourseRegistration
15
WHERE Student.loginName=:SLOGINNAME
16
AND Student.passw=:PASSW
17
AND Student.ssn=StudentCourseRegistration.studentSsn
18
AND StudentCourseRegistration.courseName=:CNAME
19
AND StudentCourseRegistration.courseOccasion=:COCCASION;";
20
$stmt = $pdo->prepare($queryString);
21
$stmt->bindParam(':SLOGINNAME', $_POST['loginName']);
22
$stmt->bindParam(':PASSW', $_POST['password']);
23
$stmt->bindParam(':CNAME', $_POST['courseName']);
24
$occation=$_POST['semester']."-".$_POST['year']." LP".$_POST['period'];
25
$stmt->bindParam(':COCCASION', $occation);
28
$count=$stmt->fetchColumn();
31
echo json_encode(array('loginSuccess' => 'true'));
33
echo json_encode(array('loginSuccess' => 'false'));
b'\\ No newline at end of file'