-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchangePassword.php
More file actions
84 lines (84 loc) · 3.14 KB
/
changePassword.php
File metadata and controls
84 lines (84 loc) · 3.14 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
<!--private-page-->
<?php
require_once("config.php");
if(!isset($_SESSION['email']))
{
header("location:index.php");
}
$details = mysqli_fetch_array(mysqli_query($al, "SELECT * FROM students WHERE email = '".$_SESSION['email']."'"));
if(!empty($_POST))
{
if(sha1($_POST['current_password']) == $details['password'])
{
if($_POST['new_password'] == $_POST['confirm_password'])
{
$sql = mysqli_query($al, "UPDATE students SET password='".sha1($_POST['new_password'])."' WHERE email='".$_SESSION['email']."'");
if($sql)
{
$msg = "Password successfully updated.";
}
else
{
$msg = "Password can't be updated. Try later.";
}
}
else
{
$msg = "Passwords don't match.";
}
}
else
{
$msg = "Wrong password entered.";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
<?php echo $details['name'];?>
</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php require("banner.php");?>
<br>
<div align="center">
<div id="box">
<span class="formHeading">Change Password</span>
<br>
<br>
<img src="profile_pictures/<?php echo $details['picture'];?>" height="100" width="100" />
<br>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table border="0" cellpadding="5" cellspacing="5">
<tr>
<td class="labels" align="center" colspan="2"><?php if(isset($msg)) {echo $msg; }?></td>
</tr>
<tr>
<td class="labels">Current Password:</td>
<td><input type="password" name="current_password" size="30" placeholder="Enter current password" required/></td>
</tr>
<tr>
<td class="labels">New Password:</td>
<td><input type="password" name="new_password" size="30" placeholder="Enter new password" required/></td>
</tr>
<tr>
<td class="labels">Confirm Password:</td>
<td><input type="password" name="confirm_password" size="30" placeholder="Re-enter new password" required/></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" value="Change Password"/></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="button" value="HOME" onClick="window.location='home.php'"></td>
</tr>
</table>
</form>
</div>
</div>
<?php require("footer.php");?>
</body>
</html>