forked from blamarche/openbookmark
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchange_password.php
69 lines (59 loc) · 1.54 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
<?php
require_once ("./header.php");
logged_in_only ();
$pw_message = null;
if (isset ($_POST['settings_password']) && $_POST['settings_password'] == 1) {
if (isset ($_POST['set_password1']) && $_POST['set_password1'] != "" &&
isset ($_POST['set_password2']) && $_POST['set_password2'] != "") {
if ($_POST['set_password1'] != $_POST['set_password2']) {
$pw_message = 'Passwords do not match.'."\n";
$password = false;
}
else {
$password = trim ($_POST['set_password1']);
}
}
else {
$pw_message = 'Please fill out both password fields.'."\n";
$password = false;
}
if ($password) {
$query = sprintf ("UPDATE user SET password=md5('%s') WHERE username='%s'",
$mysql->escape ($password),
$mysql->escape ($username));
if ($mysql->query ($query)) {
$pw_message = "Password changed.<br>\n";
}
else {
message ($mysql->error);
}
}
unset ($_POST['set_password1'], $_POST['set_password2'], $password);
}
?>
<h2 class="title">Change Password</h2>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="POST">
<table>
<tr>
<td>New Password</td>
<td><input type="password" name="set_password1"></td>
</tr>
<tr>
<td>Verify new Password</td>
<td><input type="password" name="set_password2"></td>
</tr>
<tr>
<td>
<input type="submit" value=" Save ">
<input type="button" value=" Cancel " onClick="self.close()">
<input type="hidden" name="settings_password" value="1">
</td>
<td>
<?php echo $pw_message; ?>
</td>
</tr>
</table>
</form>
<?php
require_once (ABSOLUTE_PATH . "footer.php");
?>