forked from alaxsawe/valve-servers-list
-
Notifications
You must be signed in to change notification settings - Fork 0
/
changepassword.php
executable file
·56 lines (50 loc) · 1.68 KB
/
changepassword.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
<?php
include 'core/init.php';
protect_page();
if(empty($_POST) == false) {
$fields = array('current_password', 'password', 'password_again');
foreach($_POST as $key=>$value) {
if(empty($value) && in_array($key, $fields) == true){
$errors[] = 'All fields are required';
break 1;
}
}
if(md5($_POST['current_password']) == $user_data['password']) {
if(trim($_POST['password']) !== trim($_POST['password_again'])) {
$errors[] = 'New passwords no not match!';
} elseif(strlen($_POST['password']) < 6) {
$errors[] = 'Your new password is too short!';
}
} else {
$errors[] = 'Your current password is incorrect!';
}
}
include 'includes/overall/header.php';
?>
<h2>Change Password</h2>
<?php
if(isset($_GET['success']) && empty($_GET['success'])) {
echo '<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Congratulations!</strong> Your password was successfully changed ! <a href="changepassword.php">Back</a></div>';
} else {
if(empty($_POST) == false && empty($errors) == true) {
change_password($session_user_id, $_POST['password']);
header('Location: changepassword.php?success');
} else if (empty($errors) == false) {
echo output_errors($errors);
}
?>
<form action="" method="post">
<label>Current password</label>
<input type="password" name="current_password">
<label>New Password</label>
<input type="password" name="password">
<label>New Password Again</label>
<input type="password" name="password_again"><br />
<input class="btn btn-primary" type="submit" value="Submit Password">
</form>
<?php
}
include 'includes/overall/footer.php';
?>