-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
67 lines (58 loc) · 1.27 KB
/
index.php
File metadata and controls
67 lines (58 loc) · 1.27 KB
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
<?php
session_start();
require_once('mysql_conn.php');
$err = "";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$username = $_POST['uname'];
$password = $_POST['pass'];
$sql = "SELECT * FROM login";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$un= $row['uname'];
$up= $row['pass'];
$acctype = $row['acctype'];
if($un == $username && $up == $password && $acctype=="Manager")
{
//echo 'success in manager';
$_SESSION["manager"] = $username;
header('Location: manager.php');
exit;
}
else if($un == $username && $up == $password && $acctype=="Employee")
{
$_SESSION["employee"] = $username;
header('Location: employee.php');
exit;
}
else
{
$err = 'Invalid ID or Pass';
}
}
}
?>
<html>
<head><title>Login Page</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" name="uname"></td>
</tr>
<tr>
<th>Password: </th> <td><input type="password" name="pass"></td>
</tr>
<tr>
<th> </th>
<td> <p style="color:red"><?php echo $err; ?></p>
<input type="submit" name="submit" value="Login">
</td>
</tr>
</table
</form>
</center>
</html>