forked from hammadshahir/PHP-MySQL-ecommerce-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset-password.php
116 lines (100 loc) · 3.88 KB
/
reset-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
110
111
112
113
114
115
116
<?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_reset_password = $row['banner_reset_password'];
}
?>
<?php
if( !isset($_GET['email']) || !isset($_GET['token']) )
{
header('location: '.BASE_URL.'login.php');
exit;
}
$statement = $pdo->prepare("SELECT * FROM tbl_customer WHERE cust_email=? AND cust_token=?");
$statement->execute(array($_GET['email'],$_GET['token']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
$tot = $statement->rowCount();
if($tot == 0)
{
header('location: '.BASE_URL.'login.php');
exit;
}
foreach ($result as $row) {
$saved_time = $row['cust_timestamp'];
}
$error_message2 = '';
if(time() - $saved_time > 86400)
{
$error_message2 = LANG_VALUE_144;
}
if(isset($_POST['form1'])) {
$valid = 1;
if( empty($_POST['cust_new_password']) || empty($_POST['cust_re_password']) )
{
$valid = 0;
$error_message .= LANG_VALUE_140.'\\n';
}
else
{
if($_POST['cust_new_password'] != $_POST['cust_re_password'])
{
$valid = 0;
$error_message .= LANG_VALUE_139.'\\n';
}
}
if($valid == 1) {
$cust_new_password = strip_tags($_POST['cust_new_password']);
$statement = $pdo->prepare("UPDATE tbl_customer SET cust_password=?, cust_token=?, cust_timestamp=? WHERE cust_email=?");
$statement->execute(array(md5($cust_new_password),'','',$_GET['email']));
header('location: '.BASE_URL.'reset-password-success.php');
}
}
?>
<div class="page-banner" style="background-color:#444;background-image: url(assets/uploads/<?php echo $banner_reset_password; ?>);">
<div class="inner">
<h1><?php echo LANG_VALUE_149; ?></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>";
}
?>
<?php if($error_message2 != ''): ?>
<div class="error"><?php echo $error_message2; ?></div>
<?php else: ?>
<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_100; ?> *</label>
<input type="password" class="form-control" name="cust_new_password">
</div>
<div class="form-group">
<label for=""><?php echo LANG_VALUE_101; ?> *</label>
<input type="password" class="form-control" name="cust_re_password">
</div>
<div class="form-group">
<label for=""></label>
<input type="submit" class="btn btn-primary" value="<?php echo LANG_VALUE_149; ?>" name="form1">
</div>
</div>
</div>
</form>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
<?php require_once('footer.php'); ?>