-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
111 lines (102 loc) · 3.15 KB
/
index.php
File metadata and controls
111 lines (102 loc) · 3.15 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
// Start the session
session_start();
?>
<?php
include 'Mysql_connect.php';
if(!empty($_SESSION["id"])){
switch(strlen($_SESSION["id"])){
case 1:
header("Location: /Project/AdminDesk.php");
break;
case 2:
header("Location: /Project/ManagerDesk.php");
break;
case 4:
header("Location: /Project/leaderDesk.php");
break;
case 5:
header("Location: /Project/selectorWindow.php");
break;
}
}
if(isset($_POST['username'])&&!empty($_POST['username'])&&isset($_POST['password'])&&!empty($_POST['password'])){
$username=$_POST['username'];
$password=$_POST['password'];
$sql = "SELECT id,username, password FROM User where id='".$username."' and password='".md5($password)."'";
$result = $conn->query($sql);
$num=$result->num_rows;
if ( $num> 0) {
$row = $result->fetch_assoc();
echo '<script language="javascript">';
echo 'alert("Login success';
$type="uk";
switch(strlen($row["id"])){
case 1:
$type="Admin";
echo '\n :-'.$type;
echo '")';
echo '</script>';
$_SESSION["id"] = $row["id"];
header("Location: /Project/AdminDesk.php");
break;
case 2:
$type="manager";
echo '\n :-'.$type;
echo '")';
echo '</script>';
$_SESSION["id"] = $row["id"];
header("Location: /Project/ManagerDesk.php");
break;
case 4:
$type="TLeader";
echo '\n :-'.$type;
echo '")';
echo '</script>';
$_SESSION["id"] = $row["id"];
header("Location: /Project/leaderDesk.php");
// destroy the session
break;
case 5:
$type="Employee";
echo '\n :-'.$type;
echo '")';
echo '</script>';
$_SESSION["id"] = $row["id"];
header("Location: /Project/selectorWindow.php");
break;
}
}else{
echo '<script language="javascript">';
echo 'alert("Login Failed")';
echo '</script>';
}
}
?>
<html>
<head>
<title>Login Form</title>
<link rel="stylesheet" href="css/styleIndex.css">
</head>
<body>
<section class="container">
<div class="login">
<h1>Login to Web App</h1>
<form method="post" action="index.php">
<p><input type="number" name="username" value="" placeholder="Employee id"></p>
<p><input type="password" name="password" value="" placeholder="Password"></p>
<p class="remember_me">
<label>
<input type="checkbox" name="remember_me" id="remember_me">
Remember me on this computer
</label>
</p>
<p class="submit"><input type="submit" name="commit" value="Login"></p>
</form>
</div>
<div class="login-help">
<p>Forgot your password? <a href="ForgetPassword.php">Click here to reset it</a>.</p>
</div>
</section>
</body>
</html>