-
Notifications
You must be signed in to change notification settings - Fork 7
/
changepassword.php
137 lines (77 loc) · 2.76 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
include'core/init.php';
protect_page();
?>
<?php include'includes/overall/header.php';
if(empty($_POST)===false){
$required_fields=array('oldpassword','password','repeatpassword');
//echo '<pre>',print_r($_POST,true),'</pre>'; Testing line
foreach($_POST as $key=>$value){
if(empty($value)&&in_array($value,$required_fields)===true){
$errors[]='Field Marked with asteriks are required.';
break 1;//it will come out of this loop abnd continue the execution.
}
}
$a=$_POST['oldpassword'];
$b=$_POST['password'];
$c=$_POST['repeatpassword'];
if (empty($errors)===true){
if(md5($_POST['oldpassword'])!==$user_data['password']){
$errors[]='Sorry, your current password is incorrect.';
}
if($_POST['oldpassword'] ===$_POST['password'] ){
$errors[]='Sorry, your New password should match your any of old password.';
}
if(strlen($_POST['password'])<6){
$errors[]='Sorry, The password must be atleast 6 characters';
}
if(strlen($_POST['password'])>30){
$errors[]='Sorry, The password can be atmax 30 characters';
}
if($_POST['password']!== $_POST['repeatpassword']){
$errors[]='Sorry, The password didn\'t matched.';
}
}
}
?>
<h1>Change Password</h1>
<?php
if(isset($_GET['success'])&&empty($_GET['success'])){
echo 'your password have been Updated successfully.';
}
else{
if(empty($errors)=== true && empty($_POST)===false){
change_password($session_user_id,$_POST['password']);
header('Location:changepassword.php?success');
exit();
}
else if(empty($errors)=== false){
?>
<h2>We tried to Change the password, but</h2>
<?php
echo output_errors($errors);
}
?>
<form action=" " method="POST"name="changepasswordForm" id="changepasswordForm">
<ul id= "changepasswordform" style="list-style: none;">
<li>Old Password* :<br>
<input type="password" name="oldpassword"required="required"
class="tfield" id="password" placeholder="Old Password">
</li><br>
<li>New Password* :<br>
<input type="password" name="password"required="required"
class="tfield" id="password" placeholder="New Password">
</li><br>
<li>Repeat New Password* :<br>
<input type="password" name="repeatpassword" required="required"
class="tfield" id="repeatpassword" placeholder="Confirm Password">
</li><br>
<li><br>
<input type="submit" value="Change Password">
</li><br>
</ul>
</form>
</form>
<?php
}
include 'includes/overall/footer.php';?>