-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhome_backend.php
58 lines (38 loc) · 1.21 KB
/
home_backend.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
// Checks whether user details inputted is valid. Directs flow to either student or teacher files
require('connect.php');
session_start();
if(isset($_POST['login']))
{
$userid=$_POST['userid'];
$password=$_POST['password'];
$query="SELECT * FROM login_details where userid='$userid' and password='$password'";
$result=mysqli_query($connection,$query);
if((mysqli_num_rows($result))==1)
{
if($_POST['user']=='teacher')
{
$_SESSION['loggedin'] = true;
$_SESSION['teacher_id'] = $userid;
header("Location: teacher_homepage.php");
}
else
{
$query2 = "SELECT * FROM student_info where usn='$userid'";
$result2=mysqli_query($connection,$query2);
$row2=$result2->fetch_assoc();
$_SESSION['name'] = $row2['name'];
$_SESSION['department'] = $row2['department'];
$_SESSION['semester'] = $row2['semester'];
$_SESSION['class']=$row2['class'];
$_SESSION['loggedin'] = true;
$_SESSION['student_id'] = $userid;
header("Location: student_homepage.php");
}
}
else
{
die("USER DOES NOT EXIST");
}
}
?>