-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
156 lines (136 loc) · 4.21 KB
/
index.php
File metadata and controls
156 lines (136 loc) · 4.21 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html>
<head>
<title>Change password</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript"></script>
</head>
<body>
<?php
$error = [
"username_error"=> '',
"old_password_error" => '',
"new_password_error" => '',
"confirm_password_error" => ''
];
$form_data = [
"username" => '',
"old_password" => '',
"new_password" => '',
"confirm_password" => ''
];
// if(!empty($_SESSION['error']))
// {
// $error = $_SESSION['error'];
// }
// if(!empty($_SESSION['form_data']))
// {
// $form_data = $_SESSION['form_data'];
// }
?>
<h1><center>Change Password:</center></h1>
<form action="change-password.php" method="post" onsubmit="return validate();" id="form_submission_ajax">
<table class="form-table">
<tr>
<td><label>Username:</label></td>
<td><input type="text" name="username" id="username" value="<?php echo $form_data['username']; ?>"></td>
</tr>
<tr>
<td></td>
<td id="username_error" class="error"><?php echo $error['username_error']; ?></td>
</tr>
<tr>
<td><label>Old password:</label></td>
<td><input type="password" name="old_password" id="old_password" value="<?php echo $form_data['old_password']; ?>"></td>
</tr>
<tr>
<td></td>
<td id="old_password_error" class="error"><?php echo $error['old_password_error']; ?></td>
</tr>
<tr>
<td><label>New Password:</label></td>
<td><input type="password" name="new_password" id="new_password" value="<?php echo $form_data['new_password']; ?>"></td>
</tr>
<tr>
<td></td>
<td id="new_password_error" class="error"><?php echo $error['new_password_error']; ?></td>
</tr>
<tr>
<td><label>Confirm Password:</label></td>
<td><input type="password" name="confirm_password" id="confirm_password" value="<?php echo $form_data['confirm_password']; ?>"></td>
</tr>
<tr>
<td></td>
<td id="confirm_password_error" class="error"><?php echo $error['confirm_password_error']; ?></td>
</tr>
<tr>
<td></td>
<td>
<!-- <input type="hidden" name="user_id" id="user_id" value="1"> -->
<input type="submit" name="submit" value="Submit">
</td>
</tr>
</table>
</form>
</body>
<script type="text/javascript">
function validate()
{
var valid = true;
var old_password = $('#old_password').val();
var new_password = $('#new_password').val();
var confirm_password = $('#confirm_password').val();
if(old_password=='' || old_password==null)
{
valid=false;
$('#old_password_error').html("* This field is required.");
}
else
{
$('#old_password_error').html("");
}
if(new_password=='' || new_password==null)
{
valid=false;
$('#new_password_error').html("* This field is required.");
}
else
{
$('#new_password_error').html("");
}
if(confirm_password=='' || confirm_password==null)
{
valid=false;
$('#confirm_password_error').html("* This field is required.");
}
else
{
$('#confirm_password_error').html("");
}
if(new_password != '' && confirm_password != '')
{
if(new_password != confirm_password)
{
valid = false;
$('#confirm_password_error').html("* Confirm password is same as new password.");
}
if(new_password == confirm_password)
{
$('#confirm_password_error').html("");
}
}
if(valid==true)
{
return true;
}
else
{
return false;
}
}
</script>
</html>
<?php
$_SESSION['error'] = "";
$_SESSION['form_data'] = "";
?>