/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 DuggaSys/quizAjax/getStudentCourseRegistrations.php

  • Committer: Erik Wikström
  • Date: 2013-03-28 07:43:18 UTC
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: wikxen@gmail.com-20130328074318-9v6krijkyap59nct
Removed trunk folder and moved its contents to the root

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
////Returns "loginSuccess=>true" if student login name and password is correct and list of course registrations the student is registered for, else "loginSuccess=>false";
3
 
////Parameters: loginName, password
4
 
////Returns loginSucces: true/false, array(courseName, courseOccasion)
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 "../../php/dbconnect.php";
12
 
 
13
 
$queryString="SELECT Student.ssn
14
 
                          FROM Student
15
 
                          WHERE Student.loginName=:LOGINNAME
16
 
                                AND Student.passw=:PASSW;";
17
 
$stmt = $pdo->prepare($queryString);
18
 
$stmt->bindParam(':LOGINNAME', $_POST['loginName']);
19
 
$stmt->bindParam(':PASSW', $_POST['password']);
20
 
$stmt->execute();
21
 
$count=$stmt->rowCount();
22
 
if($count==1) { //login successfull
23
 
        $studentData=$stmt->fetch(PDO::FETCH_ASSOC);
24
 
        $queryString="SELECT StudentCourseRegistration.courseName, StudentCourseRegistration.courseOccasion
25
 
                                  FROM StudentCourseRegistration
26
 
                                  WHERE studentSsn=:SSN;";
27
 
        $stmt = $pdo->prepare($queryString);
28
 
        $stmt->bindParam(':SSN', $studentData['ssn']);
29
 
        $stmt->execute();
30
 
        $listOfCourseRegistrations=array();
31
 
        $courseRegistrations=$stmt->fetchAll(PDO::FETCH_ASSOC);
32
 
        foreach($courseRegistrations as $row) {
33
 
                array_push($listOfCourseRegistrations, array('courseName'=>$row['courseName'],'courseOccasion'=>$row['courseOccasion']));
34
 
        }
35
 
        echo json_encode(array('loginSuccess' => 'true','courseRegistrations'=>$listOfCourseRegistrations));
36
 
} else {
37
 
        echo json_encode(array('loginSuccess' => 'false'));
38
 
}
39
 
 
40
 
?>
 
 
b'\\ No newline at end of file'