/
studentLogin.php
37 lines (33 loc) · 1.05 KB
/
studentLogin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
if(!session_id())
session_start();
if(isset($_POST["login"]))
{
$studentusername =$_POST['membername'];
$loginpassword=$_POST['studentpassword'];
include 'connect.php';
//echo $studentID . "<br>";
$sql = "SELECT * FROM Student WHERE Student_Username = '$studentusername';";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$confirmPass = $row["Student_Password"];
$_SESSION["firstname"] = $row["Student_FName"];
$_SESSION["memberusername"] = $row["Student_Username"];
$_SESSION["studentnumber"] = $row["Student_Number"];
$_SESSION['membership'] = $row["Membership_ID"];
}
} else {
echo "Error <br>";
}
//check password and go to student portal if it is correct
if(strcmp($confirmPass, $loginpassword) == 0 && $loginpassword != ""){
$_SESSION['studentlogin'] = 1;
header('Location: student_portal.php');
exit();
}
else echo"<script>window.alert('Incorrect username or password.');</script>";
$conn->close();
}
?>