-
Notifications
You must be signed in to change notification settings - Fork 0
/
changePassword.php
66 lines (63 loc) · 1.78 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
<?php
include("include/collegeconnection.php");
include("include/authentication.php");
if (isset($_POST['password']))
{
$conPass = $_POST['conPass'];
$pass = $_POST['password'];
$newPass = $_POST['newPass'];
$wrongpass=false;
$badpass = false;
$data = mysql_query("SELECT password from login WHERE password = '".$pass."';", $connection) or die('error');
if(mysql_num_rows($data) == 0)
{
$wrongpass= true;
}
else if($conPass != $newPass)
{
$badpass = true;
}
else
{
mysql_query('UPDATE login SET password = "'.$newPass.'" WHERE password="'.$pass.'" AND id='.$_COOKIE['userid'].' AND auth_key="'.$_COOKIE['AK'].'";', $connection) or die('error');
print '<p class="success">Password Changed!</p>';
die('<a href="login.php">Back</a>');
}
}
include("include/header.php");
?>
<div id="mainContentPart">
<div class="schoolIndexCenterbox">
<?php
if($wrongpass)
{
print '<p class="error">Wrong Password</p>';
print '<a href="login.php">Back</a>';
}
else if($badpass)
{
print '<p class="error">New Passwords do not match. Make sure you typed them correctly.</p>';
}
?>
<p class="pagetitle">Password Change</p>
<table>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method='post'>
<tr><td>
<label for="oldpassword"><font color="#454b65">Old password:</font></label></td><td>
<input type="password" name="password"></input>
</td></tr>
<tr><td>
<label for="newpassword"><font color="#454b65">New password:</font></label></td><td>
<input type="password" name="newPass"></input>
</td></tr>
<tr><td>
<label for="conpassword"><font color="#454b65">Retype new password:</font></label></td><td>
<input type="password" name="conPass"></input>
</td></tr>
<tr><td>
<input type="submit" value="Change Password"></input>
</td></tr>
</form>
</table>
</div>
</div>