-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
100 lines (89 loc) · 3.96 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
<?php ob_start(); ?>
<?php require_once('database/connection.php') ?>
<?php include_once('linker.php') ?>
<?php include_once('validate_server_side.php') ?>
<a href="index.php" class="btn btn-primary m-auto d-flex justify-content-center text-center">Return to Home</a>
<?php
if (isset($_POST['login'])) {
$data = $_POST;
// print_r($data);
// echo "<br><br>";
$loginArr = validateLoginData($conn, $data);
extract($loginArr);
// check if credentials are okay, and email is verified
$sql = "SELECT * FROM author_information WHERE author_email='$email'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$user = mysqli_fetch_assoc($result);
extract($user);
if (password_verify($password, $author_password)) {
// $encrypted_password = password_hash($password, PASSWORD_DEFAULT);
// echo $encrypted_password;
$sql_pass = "SELECT * FROM author_information WHERE author_password='$author_password'";
$result_pass = mysqli_query($conn, $sql_pass);
if (mysqli_num_rows($result_pass) > 0) {
// if (!empty($remember)) {
// setcookie("email", $email, time() + 3600);
// setcookie("password", $password, time() + 3600);
// } else {
// setcookie("email", "");
// setcookie("password", "");
// }
// echo "<p>Your login logic here</p>";
// if ($email && $password) {
if (!empty($email_verified_at)) {
$_SESSION['author_id'] = $author_id;
// $_SESSION['author_name'] = $author_name;
// $_SESSION['author_email'] = $author_email;
header("Location: author/index.php");
ob_end_flush();
} else {
header("Location: email-verification.php?email=" . $email);
ob_end_flush();
}
}
} else {
echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Invalid Password</p>";
}
} else {
echo "<p class='text-danger text-bold text-center fs-5 mt-3'>Invalid Email</p>";
}
// }
}
// else {
// echo "<label class='text-danger'>Invalid captcha!</label>";
// }
?>
<div class="container my-5 d-flex justify-content-center">
<div class="col-md-5 col-12">
<div class="card rounded m-auto py-4 px-5 shadow">
<form action="" method="post" onsubmit="return loginFormData()">
<h3 class="text-center">Login</h3>
<div class="mb-3">
<label for="email">Email address</label>
<input type="email" class="form-control" name="email" id="email" placeholder="Enter Your Email Address" onkeyup="validateEmail()" required />
<span id="email_err" class="text-danger"></span>
</div>
<div class="mb-3">
<label for="password">Password</label>
<input type="password" class="form-control" name="password" id="password" placeholder="Enter Your Password" onkeyup="validatePassword()" required />
<span id="password_err" class="text-danger"></span>
</div>
<div class="">
<button type="submit" class="btn btn-primary" name="login">
Login
</button>
</div>
<p class="forgot-password text-right mt-2">
<a href="forget_password.php">Forgot password?</a>
</p>
<p class="forgot-password text-right">
Do you have any account?
<a href="registration.php">sign up?</a>
</p>
</form>
<script src="validate_client_side.js"></script>
</div>
</div>
</div>
<?php include_once('footer.php') ?>