-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchangepass.php
More file actions
64 lines (50 loc) · 1.46 KB
/
Copy pathchangepass.php
File metadata and controls
64 lines (50 loc) · 1.46 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
<?php
/** include header **/
include("header.php");
/** set page name **/
$page = 'changepass';
/** reset error & success vars **/
$error = 0;
$error_message = '';
$success = 0;
/** change password **/
if(isset($_POST['task']) && $_POST['task'] == 'changepass')
{
/** get users curret information **/
$user = @mysql_fetch_array(@mysql_query("SELECT * FROM members WHERE id = '".$userid."' LIMIT 1"));
/** get current password **/
$current_pass = $user['password'];
/** get new password **/
$new_pass = $_POST['new_pass'];
/** check if new passwords match **/
if($new_pass != $_POST['new_pass2'])
{
$error = 1;
$error_message = 'New passwords don\'t match.';
}else
/** check old password **/
if($current_pass != sha1($_POST['current_pass']))
{
$error = 1;
$error_message = 'Current password does not match one on file.';
}else
/** check for empty fields **/
if(empty($_POST['current_pass']) || empty($_POST['new_pass']) || empty($_POST['new_pass2']))
{
$error = 1;
$error_message = 'Please fill all required fields.';
}else
/** no error?, update password **/
if($error != 1)
{
/** sha1 password **/
$new_pass = sha1($new_pass);
/** update password **/
mysql_query("UPDATE members SET password = '".mysql_real_escape_string($new_pass)."' WHERE id = '".$userid."'");
/** set success **/
$success = 1;
}
}
/** include footer **/
include("footer.php");
?>