-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
64 lines (53 loc) · 1.8 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
<?php
session_start();
error_reporting(0);
if ($_SESSION['LoggedInUser']) {
header("Location: clients.php");
}
include ('includes/functions.php');
if (isset($_POST['Login'])) {
$FormEmail = ValidateFormData($_POST['Email']);
$FormPass = ValidateFormData($_POST['Password']);
include ('includes/connection.php');
$Query = "SELECT Name, Password FROM Users WHERE Email = '$FormEmail'";
$Result = mysqli_query($Connection, $Query);
if (mysqli_num_rows($Result) > 0) {
while ($Row = mysqli_fetch_assoc($Result)) {
$Name = $Row['Name'];
$HashedPass = $Row['Password'];
}
if (password_verify($FormPass, $HashedPass)) {
$_SESSION['LoggedInUser'] = $Name;
header("Location: clients.php");
}
else {
$LoginError = "<div class='alert alert-danger'>Wrong Usernmae / Password Combination. Try Again.</div>";
}
}
else {
$LoginError = "<div class='alert alert-danger'>NO Such user in Database. Please Try Again. <a class='close' data-dismiss='alert'>×</a></div>";
}
mysqli_close($Connection);
}
include ('includes/header.php');
?>
<h1>Client Address Book</h1>
<p class="lead">Log in to your account.</p>
<?php
echo $LoginError; ?>
<form class="form-inline" action="<?php
$_SERVER['PHP_SELF'] ?>" method="post">
<div class="form-group">
<label for="login-email" class="sr-only">Email</label>
<input type="text" focusonly class="form-control" id="login-email" placeholder="email" name="Email" value="<?php
echo $FormEmail; ?>">
</div>
<div class="form-group">
<label for="login-password" class="sr-only">Password</label>
<input type="password" class="form-control" id="login-password" placeholder="password" name="Password">
</div>
<button type="submit" class="btn btn-primary" name="Login">Login</button>
</form>
<?php
include ('includes/footer.php');
?>