forked from Avinm/QuickSlots
/
login.php
79 lines (73 loc) · 2.35 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
72
73
74
75
76
77
78
79
<?php
/**
* Provides interface and back end routines that handle user logins
* @author Avin E.M; Kunal Dahiya
*/
require_once ('connect_db.php');
require_once ('functions.php');
if($_POST)
{
if(!empty($_POST['uName']) && !empty($_POST['pswd']))
{
$uName = strtolower($_POST['uName']);
$query = $db->prepare('SELECT * FROM faculty WHERE uName = ?');;
$query->execute([$uName]);
$faculty = $query->fetch();
if(!$faculty)
postResponse("error", "Username is not registered!");
if($faculty['pswd'] == pwdHash($uName, $_POST['pswd']) ||
@ldap_bind(ldap_connect($config['ldap_host']), "uid=$uName," . $config['ldap_dn'],$_POST['pswd']))
{
$_SESSION['logged_in'] = true;
$_SESSION['fName'] = $faculty['fac_name'];
$_SESSION['uName'] = $uName;
$_SESSION['level'] = $faculty['level'];
$_SESSION['dept'] = $faculty['dept_code'];
}
else
postResponse("error", "Invalid credentials");
}
}
if(sessionCheck('logged_in'))
{
$home = "faculty.php";
if($_SESSION['level'] == "dean")
$home = "dean.php";
if($_POST)
postResponse("redirect", $home);
header("Location: " . $home);
die();
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
<script src="js/jquery.min.js"></script>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<title>QuickSlots | Login</title>
<script src="js/form.js"></script>
</head>
<body class="center">
<div class="vspacer"></div>
<div class="box middle">
<div class="boxbg"></div>
<div class="elements">
<div class="avatar"><div class="icon key"></div></div>
<div class="title">Login</div>
<form id="loginform" method="post" action="login.php">
<input type="text" name="uName" class="styled username" required placeholder="Username/Roll No." />
<input type="password" name="pswd" class="styled pswd" required placeholder="Password" />
<div class="blocktext info"></div>
<div class="center button" >
<button>Login</button>
<div class="loader">
</div>
</div>
</form>
</div>
</div>
<div id="footer" style="margin:0">Powered by <a href="https://github.com/0verrider/QuickSlots">QuickSlots v1.0</a></div>
</body>
</html>