-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresetpass.php
More file actions
125 lines (97 loc) · 2.82 KB
/
resetpass.php
File metadata and controls
125 lines (97 loc) · 2.82 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
<?php
/*
* @Author: Chad Hirsch
* @package Lawyer Case Management System
* (c) November 2019
*/
require_once 'conn.php';
$user_login = new USER();
echo" <title>Reset Password</title>";
include"includes/nav.php";
//Validate URL
if(empty($_GET['id']) && empty($_GET['code']))
{
$user->redirect('index.php');
}
if(isset($_GET['id']) && isset($_GET['code']))
{
$id = base64_decode($_GET['id']);
$code = $_GET['code'];
//Check token
$stmt = $user->runQuery("SELECT * FROM tbl_users WHERE userID=:uid AND tokenCode=:token");
$stmt->execute(array(":uid"=>$id,":token"=>$code));
$rows = $stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() == 1)
{
if(isset($_POST['btn-reset-pass']))
{
$pass = $_POST['pass'];
$cpass = $_POST['confirm-pass'];
if($cpass!==$pass)
{
$msg = "<div class='alert alert-block'>
<button class='close' data-dismiss='alert'>×</button>
<strong>Sorry!</strong> Password Doesn't match.
</div>";
}
else
{
$password = md5($cpass);
//Update password
$stmt = $user->runQuery("UPDATE tbl_users SET userPass=:upass WHERE userID=:uid");
$stmt->execute(array(":upass"=>$password,":uid"=>$rows['userID']));
$msg = "<div class='alert alert-success'>
<button class='close' data-dismiss='alert'>×</button>
Password Changed.
</div>";
header("refresh:5;login.php");
}
}
}
else
{
$msg = "<div class='alert alert-success'>
<button class='close' data-dismiss='alert'>×</button>
No Account Found, Try again
</div>";
}
}
?>
<div class="page-content">
<section class="striped">
<div class="container">
<div class="row">
<div class="mainArea-first col-xs-12 col-md-7 col-lg-8">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Reset your account password</h3>
</div>
<div class="panel-body">
<form class="form-signin" method="post">
<h3 class="form-signin-heading">Password Reset.</h3><hr />
<?php
if(isset($msg))
{
echo $msg;
}
?>
<div class="form-group">
<label>New Password</label>
<input type="password" class="form-control" placeholder="New Password" name="pass" required />
</div>
<div class="form-group">
<label>Confirm New Password</label>
<input type="password" class="form-control" placeholder="Confirm New Password" name="confirm-pass" required />
<hr />
</div>
<button class="btn btn-large btn-success" type="submit" name="btn-reset-pass">Reset Your Password</button>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
<?php
include"includes/footer.php";
?>