-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
192 lines (127 loc) · 4.56 KB
/
index.php
File metadata and controls
192 lines (127 loc) · 4.56 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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
include_once "ui/conndb.php";
session_start();
date_default_timezone_set("Asia/Manila");
if (isset($_POST['btn_login'])) {
$username = $_POST['txt_username'];
$password = $_POST['txt_password'];
$select = $pdo->prepare("select * from tbl_user where username='$username' AND userpassword='$password'");
$select->execute();
$row = $select->fetch(PDO::FETCH_ASSOC);
if (is_array($row)) {
if ($row['username'] == $username and $row['userpassword'] == $password and $row['role'] == "Admin") {
$_SESSION['status']="Login Success By Admin";
$_SESSION['status_code']="success";
// Update the login time
$update = $pdo->prepare("UPDATE tbl_user SET logintime = NOW() WHERE username = :username");
$update->bindParam(':username', $username);
$update->execute();
header('refresh: 1;ui/dashboard.php');
$_SESSION['user_id']=$row['user_id'];
$_SESSION['username'] = $row['username'];
$_SESSION['userpassword'] = $row['userpassword'];
$_SESSION['role'] = $row['role'];
}else if($row['username'] == $username and $row['userpassword'] == $password and $row['role'] == "User"){
$_SESSION['status']="Login Success By User";
$_SESSION['status_code']="success";
header('refresh: 3;ui/userdine_in.php');
$_SESSION['user_id']=$row['user_id'];
$_SESSION['username'] = $row['username'];
$_SESSION['userpassword'] = $row['userpassword'];
$_SESSION['role'] = $row['role'];
}
} else {
// echo $success = "Wrong Email or Password";
$_SESSION['status']="Wrong Username or Password";
$_SESSION['status_code']="error";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Admin Panel | Login Page</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
<link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="dist/css/adminlte.min.css">
<link rel="stylesheet" href="plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
<link rel="stylesheet" href="plugins/toastr/toastr.min.css">
</head>
<body class="hold-transition login-page">
<div class="login-box">
<div class="login-logo">
<a href="index.php"><img src="./ui/iconspng/addon.png" alt="Admin Panel Logo" class="img-fluid" style="max-width: 100px;">PANEL</a>
</div>
<div class="card">
<div class="card-body login-card-body">
<p class="login-box-msg">Sign in to start your session</p>
<form action="" method="post">
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Username" name="txt_username" required>
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-user-circle"></span>
</div>
</div>
</div>
<div class="input-group mb-3">
<input type="password" class="form-control" placeholder="Password" name="txt_password" required>
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-lock"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-8">
</div>
<div class="col-4">
<button type="submit" class="btn btn-primary btn-block" name="btn_login">Login</button>
</div>
</div>
</form>
<div class="social-auth-links text-center mb-3">
</div>
</div>
</div>
</div>
<script src="plugins/jquery/jquery.min.js"></script>
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="dist/js/adminlte.min.js"></script>
<script src="plugins/sweetalert2/sweetalert2.min.js"></script>
<script src="plugins/toastr/toastr.min.js"></script>
</body>
</html>
<?php
if(isset($_SESSION['status']) && $_SESSION['status']!='')
{
?>
<script>
$(function() {
var Toast = Swal.mixin({
toast: true,
position: 'top',
showConfirmButton: false,
timer: 5000
});
Toast.fire({
icon: '<?php echo $_SESSION['status_code'];?>',
title: '<div style="text-align: center;margin-top:0.6em"><?php echo $_SESSION['status'];?></div>',
customClass: {
popup: 'small-swal'
}
})
});
</script>
<style>
.small-swal {
width: 250px !important;
padding: 10px !important;
}
</style>
<?php
unset($_SESSION['status']);
}
?>