-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
178 lines (131 loc) · 5.16 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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
include_once("includes/Database.php");
include_once("includes/functions.php");
session_start();
// var_dump($_SESSION);exit;
if (isset($_SESSION['id'])){
header("Location: index.php");
}
if (isset($_POST['loginBtn'])){
$email = $_POST['email'];
$password = $_POST['password'];
$conn = getconnection();
$username = mysqli_real_escape_string($conn,$email);
$password = mysqli_real_escape_string($conn,$password);
if(empty($username)||empty($password)){
header("Location: login.php?status=Fill All Fields");
}
else{
$loginas;
$found_account = loginAttempt($username, $password);
if($found_account === null){
header("Location: login.php?status=Invalid Username or Password");
}else{
$loginas = $found_account["employee_role"];
session_start();
if($loginas===null){
header("Location: login.php?status=You are no longer part of company!");
}else{
$_SESSION["id"] = $found_account["employee_id"];
$_SESSION["name"] = $found_account["employee_NAME"];
$_SESSION["username"] = $found_account["employee_username"];
$_SESSION["email"] = $found_account["employee_email"];
$_SESSION["role"] = $loginas;
$_SESSION["location"] = $found_account["name_location"];
if (strtolower($loginas) == "entry maker"){
header("Location: addattendanceentry.php");
}else{
header("Location: index.php");
}
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>NPM- Login</title>
<!-- plugins:css -->
<link rel="stylesheet" href="vendors/iconfonts/mdi/css/materialdesignicons.min.css">
<link rel="stylesheet" href="vendors/css/vendor.bundle.base.css">
<link rel="stylesheet" href="vendors/css/vendor.bundle.addons.css">
<!-- endinject -->
<!-- plugin css for this page -->
<!-- End plugin css for this page -->
<!-- inject:css -->
<link rel="stylesheet" href="css/style.css">
<!-- endinject -->
<link rel="shortcut icon" href="images/website_icon.png" />
</head>
<body>
<div class="container-scroller">
<div class="container-fluid page-body-wrapper full-page-wrapper auth-page">
<div class="content-wrapper d-flex align-items-center auth auth-bg-1 theme-one">
<div class="row w-100">
<div class="col-lg-4 mx-auto">
<div class="auto-form-wrapper">
<form action="login.php" method="post">
<div class="col-md-12" style="" >
<img src="images/login-logo.svg" alt="logo" />
</div>
<br>
<div class="form-group">
<label class="label">Username</label>
<div class="input-group">
<input type="email" class="form-control" placeholder="Email" name="email">
<div class="input-group-append">
<span class="input-group-text">
<i class="mdi mdi-check-circle-outline"></i>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="label">Password</label>
<div class="input-group">
<input type="password" class="form-control" placeholder="*********" name="password">
<div class="input-group-append">
<span class="input-group-text">
<i class="mdi mdi-check-circle-outline"></i>
</span>
</div>
</div>
</div>
<div class="form-group">
<button class="btn btn-success submit-btn btn-block" name="loginBtn" style="background:#006a4a;">Login</button>
</div>
<div class="form-group d-flex justify-content-between">
<a href="#" class="text-small forgot-password text-black">Forgot Password</a>
</div>
<br>
<?php if (isset($_GET['status'])){
echo "<span style='color:red'>".$_GET['status']."</span>";
} ?>
</form>
</div>
<br>
</div>
</div>
<div class="fixed-bottom">
<p class="footer-text text-right" style="font-size: 15px;padding-bottom:0px;margin-bottom:0px;">A product developed by <img src = "images/logo_white.svg" alt="NPM Logo" width="70px" height="70px"/></p>
</div>
</div>
<!-- content-wrapper ends -->
</div>
<!-- page-body-wrapper ends -->
</div>
<!-- container-scroller -->
<!-- plugins:js -->
<script src="vendors/js/vendor.bundle.base.js"></script>
<script src="vendors/js/vendor.bundle.addons.js"></script>
<!-- endinject -->
<!-- inject:js -->
<script src="js/off-canvas.js"></script>
<script src="js/misc.js"></script>
<!-- endinject -->
</body>
</html>