-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
83 lines (73 loc) · 1.73 KB
/
index.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
session_start();
require_once('mysql_conn.php');
$err = "";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$username = $_POST['uid'];
$password = $_POST['pass'];
$sql = "SELECT * FROM users";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$un= $row['user_id'];
$up= $row['pass'];
$acctype = $row['role'];
if($un == $username && $up == $password && $acctype=="Admin")
{
//echo 'success in admin';
$_SESSION["admin"] = $username;
header('Location: admin.php');
exit;
}
else if($un == $username && $up == $password && $acctype=="Teacher")
{
$_SESSION["teacher"] = $username;
header('Location: t_dashboard.php');
exit;
/*$sql1 = "SELECT * FROM `user_info`";
$result1 = mysql_query($sql1);
$row1 = mysql_fetch_array($result1);
$active = $row1['active'];
if ($active ==1) {
}*/
}
else if($un == $username && $up == $password && $acctype=="Student")
{
$_SESSION["student"] = $username;
header('Location: s_dashboard.php');
exit;
}
else
{
$err = 'Invalid ID or Pass';
}
}
}
?>
<html>
<head><title>Home Page || Online Quiz Test</title></head>
<center>
<h1>Login Page</h1>
<hr>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]) ?>" method="POST">
<table>
<tr>
<th>User ID: </th>
<td><input type="text" id="uid" name="uid"></td>
</tr>
<tr>
<th>Password: </th>
<td><input type="password" id="pass" name="pass"></td>
</tr>
<tr>
<th> </th>
<td> <p style="color:red"><?php echo $err; ?></p>
<input type="submit" name="submit" value="Login">
</td>
</table
</form>
Are you want to be a Teacher or Student?<br>
<a href="signup.php">Sign Up Here</a>
</center>
</html>