-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangestaff.php
More file actions
98 lines (84 loc) · 1.88 KB
/
changestaff.php
File metadata and controls
98 lines (84 loc) · 1.88 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
<?php
session_start();
$host="localhost";
$user="root";
$password="";
$db="Hogwarts";
$con=mysqli_connect("localhost","root","");
mysqli_select_db($con,$db);
$ID=$_SESSION['ID'];
$username = $_SESSION['username'];
$_SESSION['ID'] = $ID;
$sql="SELECT `pass` FROM `login` WHERE uname = '$username'";
$result = $con->query($sql);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$pass=$row['pass'];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>change Password</title>
<link rel="stylesheet" type="text/css" href="login.css">
</head>
<body>
<div class="Menu">
<ul>
<li><a class="active" href="studentAccount.php">Home</a></li>
</ul>
</div>
<div class="loginbox" style="height: 530px; top: 380px;">
<img src="p2.png" class="avatar">
<h1>Change Password</h1>
<br>
<form action="#" method="POST">
<p>Enter current password</p>
<input type="password" name="oldPass">
<p>Enter new password</p>
<input type="password" name="pass1">
<p>Re-enter new password</p>
<input type="password" name="pass2">
<input type="submit" name="change" value="Confirm Change">
</form>
</div>
<a href="login.php">
<img src="p3.png" alt="Logout" style="width:50px;height:42px;border:0;position: fixed;top: 8px;right: 16px;font-size: 18px;">
</a>
</body>
</html>
<?php
if(isset($_POST['oldPass']) && isset($_POST['pass2']) && isset($_POST['pass1']))
{
$oldPass = $_POST['oldPass'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
if($pass==$oldPass)
{
if($pass2==$pass1)
{
$sql2="UPDATE `login` SET `pass`='$pass1' WHERE uname = '$username'";
$result1= mysqli_query($con,$sql2);
if($result1)
{
echo "UPDATED";
}
else
{
echo "Not Updated";
}
}
else
{
echo "Passwords not matching";
}
}
else
{
echo "Incorrect Password";
}
}
?>