-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpassword.php
74 lines (64 loc) · 2.49 KB
/
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
<?php include('utils/login_check.php'); ?>
<?php
$error = false;
if (isset($_POST['loginpass'])) {
include('utils/passwd.php');
$loginpass = $_POST['loginpass'];
$new_password = $_POST['new_password'];
$repeat_password = $_POST['repeat_password'];
if (password_verify($loginpass, $passwd) && ($repeat_password == $new_password)) {
$hash = password_hash($new_password, PASSWORD_DEFAULT);
file_put_contents('utils/passwd.php', '<?php $passwd = \''.$hash.'\'; ?>');
header('Location: logout.php');
}
$error = true;
}
?>
<?php include('utils/header.php'); ?>
<main role="main" class="container">
<h1>Change Password</h1>
<hr>
<p><strong>NOTE:</strong> You will need to relogin once password reset is successful.</p>
<form action="password.php" method="post" id="form">
<?php if ($error) { ?>
<p class="alert alert-danger">Error updating password</p>
<?php } ?>
<div class="form-group">
<label for="exampleInputEmail1">Current Password</label>
<input type="password" name="loginpass" class="form-control" id="old_password" aria-describedby="emailHelp" placeholder="Enter current password">
<small id="emailHelp" class="form-text text-muted">To change your password, enter current password</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">New Password</label>
<input type="password" name="new_password" class="form-control" id="new_password" placeholder="Password">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Repeat Password</label>
<input type="password" name="repeat_password" class="form-control" id="repeat_password" placeholder="Repeat password">
</div>
<button type="submit" id="submit-btn" disabled class="btn btn-primary">Submit</button>
</form>
</main><!-- /.container -->
<script>
$(document).ready(function(){
$('#repeat_password').on('keyup', function(){
if ($('#repeat_password').val() != $('#new_password').val()) {
$('#new_password').removeClass('is-valid');
$('#repeat_password').addClass('is-invalid');
$('#submit-btn').prop('disabled','disabled');
} else {
$('#repeat_password').removeClass('is-invalid');
$('#repeat_password').addClass('is-valid');
$('#new_password').addClass('is-valid');
$('#submit-btn').prop('disabled',false);
}
});
$('#form').on('submit', function(){
if ($('#repeat_password').val() != $('#new_password').val()) {
return false;
}
return true;
});
});
</script>
<?php include('utils/footer.php'); ?>