-
Notifications
You must be signed in to change notification settings - Fork 0
/
updatePassParent.php
189 lines (158 loc) · 6.12 KB
/
updatePassParent.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE HTML>
<html>
<head>
<script src="js/script.js"></script>
<script src="js/script.js" type="text/javascript?newversion"></script>
<link rel="stylesheet" href="css/style_Zahin.css">
<style>
.errorUpdatePass {
color: #ff0000;
font-size: 40px;
}
</style>
</head>
<body>
<?php
require_once './model_z.php';
//require_once 'js/script.js';
//require_once './LoginTutor.php';
session_start();
$cPassword = $nPassword = $rPassword = $cPasswordErr = $nPasswordErr = $rPasswordErr = "";
$counter = 0;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
/*if (empty($_POST["nPassword"])) {
$nPasswordErr = "nPassword is required";
} else {
if ($_POST["cPassword"] == $_POST["nPassword"]) {
$nPasswordErr = "New Password should not be same as the Current Password";
} else {
$nPassword = $_POST["nPassword"];
$couner++;
}
}
if (empty($_POST["rPassword"])) {
$rPasswordErr = "rPasswordErr is required";
} else {
if ($_POST["rPassword"] <> $_POST["nPassword"]) {
$rPasswordErr = "New Password not match with the Retyped Password";
} else {
$rPassword = $_POST["rPassword"];
$couner++;
}
}*/
/*$lng = 103.72;
$lat = 1.34628;
echo "<script type='text/javascript'>document.write(GetAddress(",$lat,",",$lng,"));</script>"; */
//$cPass = '<script type="text/javascript">document.write(cPass(",$cPassword,"));</script>';
$true = "t";
$cP = $_POST["cPassword"];
$rP = $_POST["rPassword"];
$nP = $_POST["nPassword"];
if (empty($_POST["nPassword"]) || empty($_POST["rPassword"]) || empty($_POST["cPassword"]) || $_POST["nPassword"] == $_POST["cPassword"] || $_POST["rPassword"] != $_POST["nPassword"]) {
$cP = $_POST["cPassword"];
$rP = $_POST["rPassword"];
$nP = $_POST["nPassword"];
$cPass = "<script>document.write(cPass('$cP'));</script>";
$nPass = "<script>document.write(nPass('$cP','$nP'));</script>";
$rPass = "<script>document.write(rPass('$nP','$rP'));</script>";
$cPasswordErr = $cPass;
$nPasswordErr = $nPass;
$rPasswordErr = $rPass;
$cPassword = $_POST["cPassword"];
$nPassword = $_POST["nPassword"];
$rPassword = $_POST["rPassword"];
} else {
$counter = 3;
$cPassword = $_POST["cPassword"];
$nPassword = $_POST["rPassword"];
$rPassword = $_POST["nPassword"];
}
// $nPass = "<script type='text/javascript'>document.write(nPass('$nP'));</script>";
//$rPass = "<script type='text/javascript'>document.write(rPass('$rP'));</script>";
// $cPasswordErr = $cPass;
//$nPasswordErr = $nPass;
// echo $a = $cPass;
// echo gettype($cPass);
// $a = number_format($cPass);
// echo gettype($a);
/* $cPasswordErr = $cPass;
$nPasswordErr = $nPass;
$rPasswordErr = $rPass;*/
//echo $cPass;
//echo "<script type='text/javascript'>document.write(v);</script>";
}
if ($counter == 3) {
$data1['Password'] = $_POST["nPassword"];
$cPasswordErr = "Wrong Password";
if ($_SESSION["passForUpdatePass"] == $_POST["cPassword"]) {
if (checkPass($data1) == null) {
if ($_POST["rPassword"] == $_POST["nPassword"]) {
$data['Password'] = $_POST["nPassword"];
$data['Email'] = $_SESSION["emailForUpdatePass"];
if (updatePass($data)) {
header("Location: workDone.php");
exit();
} else {
echo 'Not Updated';
}
}
} else {
$nPassword = "This Password is Taken";
}
} else {
$cPasswordErr = "Wrong Password";
}
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<?php include "headerPerent.html"; ?>
<script>
var v = 5;
</script>
<dev class="main">
<form id="form" method="post" onsubmit="return validateForm()" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<table>
<tr>
<td>
Current Password:
</td>
<td>
<input type="password" id="myInput" name="cPassword" value=<?php echo $cPassword ?>>
<span class="error">* <?php echo $cPasswordErr; ?></span>
</td>
</tr>
<br><br>
<tr>
<td>
New Password:
</td>
<td>
<input type="password" id="myInput" name="nPassword" value=<?php echo $nPassword ?>>
<span class="error">* <?php echo $nPasswordErr; ?></span>
</td>
</tr>
<br><br>
<tr>
<td>
Retype New Password:
</td>
<td>
<input type="password" id="myInput" name="rPassword" value=<?php echo $rPassword ?>>
<span class="error">* <?php echo $rPasswordErr; ?></span>
</td>
</tr>
<br><br>
</table>
<br>
<input type="submit" class="button2Reg buttonReg" name="submit" value="Submit">
</form>
</dev>
</body>
<?php include "footer.php"; ?>
</html>