-
Notifications
You must be signed in to change notification settings - Fork 1
/
forgetpass.php
85 lines (76 loc) · 2.96 KB
/
forgetpass.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
<?php include("header.php");?>
<?php
session_start();
if(isset($_SESSION["username"])){
header("Location: dashboard/index.php");
}
$error = "";
$sucess = "";
if (isset($_POST['forgetpass'])) {
require('db.php');
$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($con,$email);
if(empty($email)){
$error = "Please type a email first!";
}
else{
$emailquery = "SELECT * FROM users WHERE email='$email' LIMIT 1 ";
$return = mysqli_query($con,$emailquery);
$return = mysqli_num_rows($return);
echo $return;
if($return == 1){
$token = strval(bin2hex(openssl_random_pseudo_bytes(30)));
$sqlquery = "UPDATE users SET token = '$token' WHERE email='$email' LIMIT 1";
$results = mysqli_query($con, $sqlquery);
if ($results){
$to = $email;
$subject = "Homeobd pasword reset request!";
$msg = "Hi there, click on this <a href=\"resetpass.php?token=" . $token . "\">link</a> to reset your password";
$msg = wordwrap($msg,70);
$headers = "From: [email protected]";
mail($to, $subject, $msg, $headers);
$sucess = "Emailed! Please check your email to reset password!";
}
else{
echo "ERROR: Could not able to execute $sqlquery. " . mysqli_error($con);
}
}
else{
$error = "Email does not exist!";
}
}
}
?>
<body class="az-body">
<div class="az-signin-wrapper">
<div class="az-card-signin">
<h1 class="az-logo">Homeo<span>B</span>D</h1>
<div class="az-signin-header">
<h2>Forget your password?</h2>
<h4><?php echo $sucess;?></h4>
<h4 style="color:red;"><?php echo $error;?></h4>
<form method="post" action="">
<div class="form-group">
<label>Email</label>
<input name="email" type="email" class="form-control" placeholder="Enter your email">
</div><!-- form-group -->
<button type="submit" name="forgetpass" class="btn btn-az-primary btn-block">Send</button>
</form>
</div><!-- az-signin-header -->
<div class="az-signin-footer">
<p><a href="login.php">Have account? login</a></p>
<p>Don't have an account? <a href="signup.php">Create an Account</a></p>
</div><!-- az-signin-footer -->
</div><!-- az-card-signin -->
</div><!-- az-signin-wrapper -->
<script src="./old/lib/jquery/jquery.min.js"></script>
<script src="./old/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="./old/lib/ionicons/ionicons.js"></script>
<script src="./old/js/azia.js"></script>
<script>
$(function() {
'use strict'
});
</script>
</body>
</html>