forked from Vimall03/Alimento
-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_verify.php
170 lines (154 loc) · 6.17 KB
/
email_verify.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
<?php
session_start();
$login = false;
$showError = false;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include 'partials/_dbconnect.php';
$email = $_SESSION['email'];
$password = $_POST["password"];
//to check if the password/ email is blank
if ($password == '') {
$showError = "Enter valid Email/password";
}
//if not blank then go to else
else {
$sql = "SELECT * FROM `users` WHERE email = '$email' ";
$result = mysqli_query($conn, $sql);
// mysqli_query() - $conn is used to start connection to the server and runs
// the query $sql and the result is stored in $result
$num = mysqli_num_rows($result);
//mysqli_num_rows() - fetches the number of rows present in $result
if ($num == 1) {
while ($row = mysqli_fetch_assoc($result)) {
//mysqli_fetch_assoc() - fetches the associated value from t$result
// and stores it as associate array in $row
if (password_verify($password, $row['resetcode'])) {
//password_verify() - function is used to verify the the hash of the entered password
// by matching it with the password hash stored in the database.
$sql = "UPDATE `users`
SET `account_status` = 'Verified' , `resetcode` = '0'
WHERE `email` = '$email';";
$result = mysqli_query($conn, $sql);
$_SESSION['loggedin'] = true;
header("location: user_login.php");
} else {
$showError = "Invalid OTP";
}
}
} else {
$showError = "Email not registered. Click on sign up to register";
}
}
}
?>
<!-- source html code -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Verification - etiffy</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f9f9f9;
}
header {
background-color: #d5761d;
color: white;
text-align: center;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 40px 20px;
text-align: center;
}
.button {
display: inline-block;
padding: 10px 20px;
margin: 10px;
font-size: 18px;
border: none;
background-color: #d5761d;
color: white;
cursor: pointer;
text-decoration: none;
border-radius: 5px;
}
</style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous">
</script>
<!-- Alert bootstrap -->
<?php
if ($login) {
echo ' <div class="alert alert-success alert-dismissible fade show" role="alert">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check-circle-fill" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
</svg>
<strong>Congratulations!</strong> Login success.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
';
}
if ($showError) {
echo ' <div class="alert alert-danger alert-dismissible fade show" role="alert">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-exclamation-triangle-fill" viewBox="0 0 16 16">
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
</svg>
<strong>Error. </strong> ' . $showError . '
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
';
} ?>
<body>
<header>
<h1>etiffy</h1>
<p>Delicious Moments Delivered to Your Doorstep</p>
</header>
<div class="container">
<h2>Verify Your Email</h2>
<p>Enter the 8-digit code sent to your email to complete the verification process.</p>
<form action="email_verify.php" method="post">
<input type="password" name="password" maxlength="8" minlength="8" required>
<br>
<button type="submit" class="button">Verify Email</button>
</form>
<p>If you haven't received the code, please check your spam folder or request a new code.</p>
</div>
</body>
</html>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
</script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
window.embeddedChatbotConfig = {
chatbotId: "gvEIQuZ1QCpui9UuF1UWX",
domain: "www.chatbase.co"
}
</script>
<script
src="https://www.chatbase.co/embed.min.js"
chatbotId="gvEIQuZ1QCpui9UuF1UWX"
domain="www.chatbase.co"
defer>
</script>
</body>
</html>