-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgotPassword.php
109 lines (85 loc) · 3.28 KB
/
forgotPassword.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
<?php
ob_start();
require_once 'connection.php';
if (isset($_POST["forgot-password"]))
{
$user_email = mysqli_real_escape_string($conn, $_POST["user_email"]);
if (!empty($user_email))
{
if (filter_var($user_email, FILTER_VALIDATE_EMAIL))
{
$token = bin2hex(random_bytes(16));
$query = mysqli_query($conn, "SELECT email FROM user WHERE email = '$user_email' ");
$sql = mysqli_fetch_assoc($query);
//$r=mysqli_num_rows($query);
//if ($r > 0)
if (!empty($sql))
{
$query = mysqli_query($conn, "SELECT email_verified FROM user WHERE email = '$user_email' AND email_verified = '1' ");
$sql = mysqli_fetch_assoc($query);
//$r=mysqli_num_rows($query);
//if ($r > 0)
if (!empty($sql))
{
mysqli_query($conn, "UPDATE user SET forgot_password='$token' WHERE email = '$user_email' ");
$query = mysqli_query($conn, "SELECT name, email , forgot_password FROM user WHERE email = '$user_email' ");
$user = mysqli_fetch_assoc($query);
//if (!empty($user))
require_once("forgot-password-mail.php");
}
else
{
$error_message = 'Please Verify Your Email First. OR,<br>
<b><a style="color: blue" href="index.php?option=resend-email-verification">Resend Email Verification Link</a></b>
';
}
}
else
{
$error_message = 'No Email Id Found';
}
}
else
{
$error_message = 'Invalid Email Id Format';
}
}
else
{
$error_message = 'Email is required';
}
}
?>
<h2 class="text-center">Forgot Password</h2><br><br>
<form id="frmForgot" name="frmForgot" method="post">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<?php
if (!empty($success_message))
{
?><div style="font-weight: bold;color:green;"><?php
echo $success_message;
?> </div><?php
}
?>
<?php
if (isset($error_message))
{
?> <div style="font-weight: bold;color:red;"><?php
echo $error_message;
?></div> <?php
}
?>
</div>
</div>
<div class="row">
<div class="col-sm-4"><b>Enter Your Registered email Id</b></div>
<div class="col-sm-5">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="email" class="form-control" name="user_email" placeholder="Enter Your Registered email Id" required></div>
</div>
<input type="submit" class="btn btn-success" style="margin-top:10px ;margin-left:45%" value="submit" name="forgot-password" id="forgot-password">
</form>
</div>