-
Notifications
You must be signed in to change notification settings - Fork 0
/
forget-password.php
109 lines (94 loc) · 4.07 KB
/
forget-password.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 require_once('header.php'); ?>
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_settings WHERE id=1");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$banner_forget_password = $row['banner_forget_password'];
}
?>
<?php
if(isset($_POST['form1'])) {
$valid = 1;
if(empty($_POST['cust_email'])) {
$valid = 0;
$error_message .= LANG_VALUE_131."\\n";
} else {
if (filter_var($_POST['cust_email'], FILTER_VALIDATE_EMAIL) === false) {
$valid = 0;
$error_message .= LANG_VALUE_134."\\n";
} else {
$statement = $pdo->prepare("SELECT * FROM tbl_customer WHERE cust_email=?");
$statement->execute(array($_POST['cust_email']));
$total = $statement->rowCount();
if(!$total) {
$valid = 0;
$error_message .= LANG_VALUE_135."\\n";
}
}
}
if($valid == 1) {
$statement = $pdo->prepare("SELECT * FROM tbl_settings WHERE id=1");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$forget_password_message = $row['forget_password_message'];
}
$token = md5(rand());
$now = time();
$statement = $pdo->prepare("UPDATE tbl_customer SET cust_token=?,cust_timestamp=? WHERE cust_email=?");
$statement->execute(array($token,$now,strip_tags($_POST['cust_email'])));
$message = '<p>'.LANG_VALUE_142.'<br> <a href="'.BASE_URL.'reset-password.php?email='.$_POST['cust_email'].'&token='.$token.'">Click here</a>';
$to = $_POST['cust_email'];
$subject = LANG_VALUE_143;
$headers = "From: noreply@" . BASE_URL . "\r\n" .
"Reply-To: noreply@" . BASE_URL . "\r\n" .
"X-Mailer: PHP/" . phpversion() . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
$success_message = $forget_password_message;
}
}
?>
<div class="page-banner" style="background-color:#444;background-image: url(assets/uploads/<?php echo $banner_forget_password; ?>);">
<div class="inner">
<h1><?php echo LANG_VALUE_97; ?></h1>
</div>
</div>
<div class="page">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="user-content">
<?php
if($error_message != '') {
echo "<script>alert('".$error_message."')</script>";
}
if($success_message != '') {
echo "<script>alert('".$success_message."')</script>";
}
?>
<form action="" method="post">
<?php $csrf->echoInputField(); ?>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="form-group">
<label for=""><?php echo LANG_VALUE_94; ?> *</label>
<input type="email" class="form-control" name="cust_email">
</div>
<div class="form-group">
<label for=""></label>
<input type="submit" class="btn btn-primary" value="<?php echo LANG_VALUE_4; ?>" name="form1">
</div>
<a href="login.php" style="color:#e4144d;"><?php echo LANG_VALUE_12; ?></a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php require_once('footer.php'); ?>