-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkotp.php
217 lines (192 loc) · 4.45 KB
/
checkotp.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
session_start();
$success = "";
$error_message = "";
$conn = mysqli_connect("localhost", "root", "", 'safespend-2');
$count = 1;
// generate OTP
$otp = rand(100000, 999999);
// Send OTP
require_once("mail_function.php");
$mail_status = sendOTP($_SESSION['user_name'], $otp);
if ($mail_status == 1) {
$result = mysqli_query($conn, "INSERT INTO otp_expiry(otp,is_expired,create_at) VALUES ('" . $otp . "', 0, '" . date("Y-m-d H:i:s") . "')");
$current_id = mysqli_insert_id($conn);
if (!empty($current_id)) {
$success = 1;
}
}
if (!empty($_POST["submit_otp"])) {
$result = mysqli_query($conn, "SELECT * FROM otp_expiry WHERE otp='" . $_POST["otp"] . "' AND is_expired!=1 AND NOW() <= DATE_ADD(create_at, INTERVAL 24 HOUR)");
$count = mysqli_num_rows($result);
if (!empty($count)) {
$result = mysqli_query($conn, "UPDATE otp_expiry SET is_expired = 1 WHERE otp = '" . $_POST["otp"] . "'");
$success = 2;
} else {
$success = 1;
$error_message = "Invalid OTP!";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>SafeSpend | OTP Verification</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<style media="screen">
*,
*:before,
*:after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
background-color: #e5e5e5;
font-family: 'Poppins', sans-serif;
}
.background {
width: 430px;
height: 520px;
position: absolute;
transform: translate(-50%, -50%);
left: 50%;
top: 50%;
}
.background .shape {
height: 200px;
width: 200px;
position: absolute;
border-radius: 50%;
}
.shape:first-child {
background: linear-gradient(green,
#B8A52A);
left: -80px;
top: -80px;
}
.shape:last-child {
background: linear-gradient(to right,
#ff512f,
#f09819);
right: -30px;
bottom: -80px;
}
form {
height: 570px;
width: 400px;
background-color: rgba(51, 255, 61, 0.22);
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
border-radius: 10px;
backdrop-filter: blur(10px);
border: 2px solid rgba(255, 255, 255, 0.1);
box-shadow: 0 0 40px rgba(8, 7, 16, 0.6);
padding: 50px 35px;
}
form * {
font-family: 'Poppins', sans-serif;
color: #080710;
letter-spacing: 0.5px;
outline: none;
border: none;
}
form h3 {
font-size: 32px;
font-weight: 500;
line-height: 42px;
text-align: center;
}
label {
display: block;
margin-top: 30px;
font-size: 16px;
font-weight: 500;
}
input {
display: block;
height: 50px;
width: 100%;
background-color: rgba(44, 66, 45, 0.22);
border-radius: 3px;
padding: 0 10px;
margin-top: 8px;
font-size: 14px;
font-weight: 300;
}
::placeholder {
color: #e5e5e5;
}
button {
margin-top: 50px;
width: 100%;
background-color: green;
color: #080710;
padding: 15px 0;
font-size: 18px;
font-weight: 600;
border-radius: 5px;
cursor: pointer;
}
.social {
margin-top: 30px;
display: flex;
}
.social div {
background: red;
width: 150px;
border-radius: 3px;
padding: 5px 10px 10px 5px;
background-color: rgba(42, 66, 43, 0.22);
color: #eaf0fb;
text-align: center;
}
.social div:hover {
background-color: rgba(255, 255, 255, 0.47);
}
.social .fb {
margin-left: 25px;
}
.social i {
margin-right: 4px;
}
.closebutton{
display: block;
margin:0 0 auto;
background-color: transparent;
font-size: 30px;
color: #ffffff;
background: #03549a;
border-radius: 100%;
width: 40px;
height: 40px;
border: none;
outline: none;
cursor: pointer;
}
</style>
</head>
<body>
<div class="background">
<div class="shape"></div>
<div class="shape"></div>
</div>
<a href = "login.php"><button id="close" class = "closebutton">×</button></a>
<form name="frmUser" method="post">
<h2>OTP Verification</h2>
<p style="color:#000000;">Check your email for the OTP</p>
<label>OTP</label>
<input type="text" name="otp" placeholder="One Time Password" class="login-input" required><br />
<button type="submit" name="submit_otp" value="Submit" class="btnSubmit">Submit</button>
<?php
if ($success == 2) {
header("Location:budget-index.php");
}
?>
</form>
</body>
</html>