-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathforgot.php
More file actions
342 lines (261 loc) · 12.1 KB
/
forgot.php
File metadata and controls
342 lines (261 loc) · 12.1 KB
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<?php include 'controllers/authController.php' ?>
<?php
// redirect user to login page if they're not logged in
if (isset($_SESSION['id'])) {
header('location: main.php');
}
?>
<style>
@media screen and (min-width: 750px) {
#bars
{
display:none;
}
}
</style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="author" content="Kodinger">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>DiagnoX.ai - Login</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/my-login.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/fa-fonts.css">
<!-- <meta charset="utf-8">
<meta name="author" content="Kodinger">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>My Login Page — Bootstrap 4 Login Page Snippet</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/my-login.css"> -->
</head>
<body>
<div class="splash">
<!-- Header Section -->
<nav class="navbar navbar-icon-top navbar-expand-lg">
<a class="navbar-brand" href="main.php"
style="font-family: Caviar Dreams; font-size: 33px; margin-top: 30px; color: rgb(231, 69, 69)">DiagnoX.ai</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
<span class="navbar-toggler-icon"></span>
</button>
<i class="fa fa-bars" id="bars" aria-hidden="true" data-toggle="collapse" data-target="#navbarSupportedContent"></i>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul style="list-style-type: none;" style="list-style-type: none;" class="navbar-nav mr-auto">
<li class="nav-item active">
<a style="
text-decoration: none;" class="nav-link" href="main.php">
<i class="fa fa-home"></i>
Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a style="
text-decoration: none;" class="nav-link" href="prediction/predict.php">
<i class="fa fa-plus-square">
<!-- <span class="badge badge-danger">11</span> -->
</i>
Try Demo
</a>
</li>
<li class="nav-item">
<a style="
text-decoration: none;" class="nav-link" href="pricing.php">
<i class="fa fa-usd">
<!-- <span class="badge badge-danger">11</span> -->
</i>
Pricing
</a>
</li>
<li class="nav-item dropdown">
<a style="
text-decoration: none;" class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-building">
<!-- <span class="badge badge-primary">11</span> -->
</i>
Company
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a style="
text-decoration: none; margin-bottom: 15px" class="dropdown-item" href="#">About US</a>
<div class="dropdown-divider"></div>
<a style="
text-decoration: none;" class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a style="
text-decoration: none;" class="nav-link" href="contact-form.php">
<i class="fa fa-envelope">
<span class="badge badge-danger">11</span>
</i>
Contact
</a>
</li>
<!-- <li class="nav-item">
<a style="
text-decoration: none;" class="nav-link disabled" href="#">
<i class="fa fa-envelope-o">
<span class="badge badge-warning">11</span>
</i>
Disabled
</a>
</li> -->
<!-- <li class="nav-item dropdown">
<a style="
text-decoration: none;" class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-envelope-o">
<span class="badge badge-primary">11</span>
</i>
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a style="
text-decoration: none;" class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li> -->
</ul>
<div class="header-right">
<ul style="list-style-type: none;" class="navbar-nav">
<li class="nav-item">
<?php if(isset($_SESSION['email'])==null)
{
echo '<a style="
text-decoration: none;" class="nav-link" href="login.php">
<i class="fa fa-sign-in">
</i>';
echo "Login";
}
else {
echo '<a style="
text-decoration: none; color:orange;" class="nav-link" href="logout.php">
<i class="fa fa-sign-out">
</i>';
echo 'Logout';
echo "<br>";
if(isset($_SESSION['email'])) echo $_SESSION['email'];
}
?>
</a>
</li>
<li class="nav-item">
<?php if(isset($_SESSION['email'])==null)
{
echo' <a style="
text-decoration: none;" class="nav-link" href="register.php">
<i class="fa fa-user-plus">
</i>
Register
</a>';
}
?>
</li>
</ul>
</div>
<!-- <form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form> -->
</div>
</nav>
<div class="my-login-page">
<section class="h-100">
<div class="container h-100">
<div class="row justify-content-md-center align-items-center h-100">
<div class="card-wrapper">
<div class="brand">
<img src="img/logo.jpg" alt="Diagnox.ai">
</div>
<div class="card fat">
<div class="card-body">
<h4 class="card-title">Forgot Password</h4>
<form action="forgot.php" method="post" class="my-login-validation" novalidate="">
<div class="form-group">
<label for="email">E-Mail Address</label>
<input id="email" type="email" class="form-control" name="email" value="" required autofocus>
<div class="invalid-feedback">
Email is invalid
</div>
<div class="form-text text-muted">
By clicking "Reset Password" we will send a password reset link
</div>
</div>
<div class="form-group m-0">
<button type="submit" name="forgot-btn" class="btn btn-primary btn-block">
Reset Password
</button>
</div>
</form>
</div>
</div>
<div class="footer">
Copyright © 2017 — Your Company
</div>
</div>
</div>
</div>
</section>
</div>
<div>
<?php include_once('footer.html') ?>
</body>
<!-- SCRIPTS -->
<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://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="js/my-login.js"></script>
</html>
<?php
// FORGOT USER
if (isset($_POST['forgot-btn'])) {
echo'forgot';
if (empty($_POST['email'])) {
$errors['email'] = 'Email required';
}
$email = $_POST['email'];
// Check if email already exists
$sql = "SELECT * FROM users WHERE email='$email' LIMIT 1";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$token = bin2hex(random_bytes(50));
// update token
$query = "UPDATE users SET token=? where email = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param('ss', $token, $email);
$result = $stmt->execute();
if ($result) {
$stmt->close();
header('location: main.php');
}
else
{
$_SESSION['error_msg'] = "Database error: Could not register user";
}
// generate unique token
sendForgotEmail($email, $token);
// header('location: ./login.php');
}
// if (count($errors) === 0) {
// $query = "INSERT INTO users SET username=?, email=?, token=?, password=?, user_type=?";
// $stmt = $conn->prepare($query);
// $stmt->bind_param('sssss', $username, $email, $token, $password, $type);
// $result = $stmt->execute();
// if ($result) {
// $user_id = $stmt->insert_id;
// $stmt->close();
// // TO DO: send verification email to user
// sendVerificationEmail($email, $token);
// header('location: ./login.php');
// } else {
// $_SESSION['error_msg'] = "Database error: Could not register user";
// }
// }
}
?>