-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange_password.php
111 lines (52 loc) · 2.29 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
<?php $carousel="no";
include ( "./inc/header.inc.php");
if(!$userid){
die("You must be logged in to vew this page");
}
?>
<script>
$("body").css({"background": "#fff"});
</script>
<div class="profile--wrapper">
<?php
$senddata = @$_POST['change_password'];
$old_password=strip_tags(@$_POST['oldpassword']);
$new_password=strip_tags(@$_POST['newpassword']);
$repeat_password=strip_tags(@$_POST['newpassword2']);
if($senddata){
$pass=DB::query('SELECT password FROM users WHERE id=:id',array(':id'=>$userid))[0]['password'];
if (password_verify($old_password, DB::query('SELECT password FROM users WHERE id=:userid', array(':userid'=>$userid))[0]['password'])){
if($new_password == $repeat_password){
if(strlen($new_password) >=6 && strlen($repeat_password) <=60){
DB::query('UPDATE users SET password=:password WHERE id=:userid', array(':password'=>password_hash($new_password, PASSWORD_BCRYPT), ':userid'=>$userid));
echo "Password changed successfully";
}
else{
echo "Your password must be between 6 and 60 characters long";
}
}
else{
echo "New password doesn't match";
}
}
else{
echo "Incorrect old Password";
}
}
?>
<div class="form">
<div class="contact">
<div class="left-align">
<a href="<?php print $_SERVER['MYVAR'];?>settings.php" class="previous round">‹</a>
</div>
<form action="" method="POST">
<h3 id="area" class="contact__heading">Change your password</h3>
<input type="password" name="oldpassword" id="oldpassword" class="contact__input" placeholder="Enter your old password here">
<input type="password" name="newpassword" id="newpassword" class="contact__input" placeholder="Enter your new password here">
<input type="password" name="newpassword2" id="newpassword2" class="contact__input" placeholder="Retype your password here"><br><br>
<input type="submit" name="change_password" id="change_password" class="contact__final" value="Update Password">
</div>
</form>
</div>
</div>
</div>