-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
95 lines (95 loc) · 3.31 KB
/
index.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
<?php
session_start();
include 'db_config.php';
$msg='';
if(isset($_POST['signin']))
{
$user_name = mysqli_real_escape_string($con,$_POST['user_name']);
$passwd = mysqli_real_escape_string($con,$_POST['passwd']);
$verify_user_query = "SELECT count(*) FROM `user_credentials` WHERE `user_name` = '".$user_name."'";
$fetch_result = mysqli_query($con, $verify_user_query);
$users_arry = mysqli_fetch_array($fetch_result);
$user_count = $users_arry['count(*)'];
if($user_count == 1)
{
$fetch_usr_password = "SELECT `user_passwd` FROM `user_credentials` WHERE `user_name` = '".$user_name."'";
$fetch_hash_pass = mysqli_query($con, $fetch_usr_password);
$results_arry = mysqli_fetch_array($fetch_hash_pass);
$hash_password = $results_arry['user_passwd'];
if(password_verify($passwd, $hash_password))
{
$_SESSION['user_name']= $user_name;
$_SESSION['logged'] = TRUE;
header("location:dashboard.php");
}
else
{
$msg = "<div class=\"alert alert-danger alert-dismissible fade show\" role=\"alert\" align=\"center\"> <strong> Error: </strong> Invalid password for this Username!! <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" aria-label=\"Close\"></button></div>";
}
}
else
{
$msg = "<div class=\"alert alert-danger alert-dismissible fade show\" role=\"alert\" align=\"center\"> <strong> Error: </strong> No account found with the Username!! <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" aria-label=\"Close\"></button></div>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>User Login</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100 p-t-50 p-b-90">
<form class="login100-form validate-form flex-sb flex-w" method="POST">
<span class="login100-form-title p-b-51">
User Authentication
</span>
<div class="wrap-input100 validate-input m-b-16" data-validate = "Username is required">
<input class="input100" type="text" name="user_name" placeholder="Username">
<span class="focus-input100"></span>
</div>
<div class="wrap-input100 validate-input m-b-16" data-validate = "Password is required">
<input class="input100" type="password" name="passwd" placeholder="Password">
<span class="focus-input100"></span>
</div>
<div class="flex-sb-m w-full p-t-3 p-b-24">
<div class="contact100-form-checkbox">
</div>
<div>
</div>
</div>
<div class="container-login100-form-btn m-t-17">
<button class="login100-form-btn" type="submit" name="signin">
Sign In
</button>
</div>
<div class="flex-sb-m w-full p-t-3 p-b-24">
<div class="contact100-form-checkbox">
</div>
<div>
</div>
</div>
<div>
<h5>
Create an account: <a href='register.php'> <b>Register Here</b> </a>
</h5>
</div>
</form>
<div class="container">
<div class="row">
<?php echo $msg; ?>
</div>
</div>
</div>
</div>
</div>
</body>
</html>