-
Notifications
You must be signed in to change notification settings - Fork 2
/
login.php
71 lines (68 loc) · 2.2 KB
/
login.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
<html>
<head>
<title>
Login
</title>
<link rel="stylesheet" type="text/css" href="style/common.css">
</head>
<body>
<center>
<div class="main_div">
<?PHP
$con = new mysqli("localhost", "root", "", "lib_man");
$code = $_GET['code'];
switch($code)
{
case 1:
echo "<h5 color=red align=center> Please login first! </h5>";
break;
case 2:
echo "<h5 color=red align=center> Logout successful! </h5>";
}
if(isset($_POST['login']))
{
$username = $_POST['username'];
$password = md5($_POST['password']);
$com = "select * from credentials where cid='$username' and cpass='$password'";
$result = mysqli_query($con,$com);
if($row=mysqli_fetch_array($result))
{
$user_type= $row[3];
session_start();
$_SESSION['username'] = $username;
$_SESSION['state'] = "logged_in";
if($user_type=="admin")
{
$_SESSION['slevel'] = 1;
header("location:admin_home.php");
}
else if($user_type=="librarian")
{
$_SESSION['slevel'] = 2;
header("location:lib_home.php");
}
else
echo "<h5 color=red align=center> Corrupt Account Configuration </h5>";
}
else
echo "<h5 color=red align=center> Invalid USERNAME/PASSWORD </h5>";
}
else if(isset($_POST['home']))
{
session_destroy();
header("location:home.php");
}
?>
<div style="padding:40px 25px;background:rgba(128, 64, 0,0.5);width:600px;height:200px;border-radius:50px;border:1px solid black;margin:160px 0">
<h1> Library Management System </h1>
<form method="post">
<h4> Username : <input type="text" name="username"></h4>
<h4> Password : <input type="password" name="password"></h4>
<input type="submit" name="login" value="Login">
<input type="submit" name="home" value="Return to Home">
</form>
</div>
</div>
</center>
</body>
</html>