/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to trunk/DuggaSys/quizAjax/checkStudentCourseOccasion.php

  • Committer: Henrik G.
  • Date: 2013-03-26 23:22:55 UTC
  • Revision ID: henrik.gustavsson@his.se-20130326232255-ik6snyatlbkf3zs1
First seed of Lenasys ... Needs to be Organized Further

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
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
 
5
 
 
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'); 
 
10
 
 
11
include "dbconnect.php";
 
12
 
 
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);
 
26
$stmt->execute();
 
27
 
 
28
$count=$stmt->fetchColumn();
 
29
 
 
30
if($count==1){
 
31
        echo json_encode(array('loginSuccess' => 'true'));
 
32
} else {
 
33
        echo json_encode(array('loginSuccess' => 'false'));
 
34
}
 
35
 
 
36
?>
 
 
b'\\ No newline at end of file'