-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange_password.php
95 lines (56 loc) · 2 KB
/
change_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
<?
include("logincheck.php");
$userpkey = $_SESSION['userpkey'];
include("includes/config.inc.php");
include("db.php");
$count=$db->get_var("select count(*) from users where pkey=$userpkey");
if($count > 0){
if($_POST['submit']!=""){
//check passwords
$currentpassword=$_POST['currentpassword'];
$password=$_POST['password'];
$passwordconfirm=$_POST['passwordconfirm'];
if($password==""){
$error.=$errordelim."Password cannot be blank.";$errordelim="<br>";
}
if($password!=""){
if($password != $passwordconfirm){
$error.=$errordelim."Passwords do not match.";$errordelim="<br>";
}
}
//check current password
$count = $db->get_var("select count(*) from users where crypt('$currentpassword', password) = password and pkey=$userpkey");
if($count==0){
$error.=$errordelim."Incorrect current password provided.";$errordelim="<br>";
}
if($error==""){
//update password
$db->query("update users set password=crypt('$password', gen_salt('md5')) where pkey=$userpkey");
include("includes/header.php");
?>
<h1>Success</h1><br><br>
Password has been reset.
<?
include("includes/footer.php");
exit();
}
}
if($error!=""){
$error="<div style=\"color:#FF0000;padding:10px;\">$error</div>";
}
include("includes/header.php");
?>
<h2>Password Reset:</h2><br>
<?=$error?>
<form method="POST">
<table>
<tr><td>Current Password</td><td><input type="password" name="currentpassword" value="<?=$currentpassword?>"></td></tr>
<tr><td>New Password</td><td><input type="password" name="password" value="<?=$password?>"></td></tr>
<tr><td>Confirm Password</td><td><input type="password" name="passwordconfirm" value="<?=$passwordconfirm?>"></td></tr>
<tr><td colspan="2"><div align="center"><input type="submit" name="submit" value="Submit"></div></td></tr>
</table>
</form>
<?
include("includes/footer.php");
}
?>