-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChangePass.php
122 lines (116 loc) · 3.08 KB
/
ChangePass.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
p{
font-size:20px;
font-weight:bold;
color:red;
text-align:center;
}
body{
margin:0;
padding:0;
}
.image{
margin:0;
padding:0;
}
#box{
margin-left:150px;
margin-right:150px;
}
#fill{
border:2px solid red;
width:1000px;
padding:10px;
margin:20px;
}
.navbar{
overflow:hidden;
background-color:#333;
font-family:'PT Sans', sans-serif;
}
.navbar a{
float:left;
display:block;
color:white;
text-align:center;
padding:14px 20px;
text-decoration:none;
.navbar a:hover{
background-color:#ddd;
color:black;
}
#side{
margin-left:30px;
}
</style>
</head>
<body>
<div class="image">
<img src="img2.jpg" height="400" width="1390">
<div class="navbar">
<a href="HomeNew.php">Home</a>
<a href="ChangePass.php">Change Password</a>
<a href="UpdateProfile.php">Update Profile</a>
<a href="DonateInfo.php">Donate Blood</a>
<a href="BloodInfo.php">Blood Donated</a>
<a href="View_Request1.php">View Request</a>
<a href="Home.php">Logout</a>
</div>
</br>
<div style="margin-left:150px;margin-right:150px">
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<p style="color:red;font-size:20px;text-align:center;font-weight:bold">CHANGE PASSWORD </p>
<div style="text-align:center;border:2px solid red;width:1000px;padding:10px;margin:20px">
<b>OLD PASSWORD</b>
<input type="password" placeholder="Old Password" name="oldpass" style="width:200px;margin-left:62px" required></br></br>
<b>NEW PASSWORD</b>
<input type="password" placeholder="New Password" name="newpass" style="width:200px;margin-left:62px" required></br></br>
<b>CONFIRM PASSWORD</b>
<input type="password" placeholder="Conform Password" name="confpass" style="width:200px;margin-left:25px" required></br></br>
<input type="submit" value="update" style="width:100px">
</div>
</form>
</div>
</div>
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "aa";
$dbname = "bloodbank";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname, 3308);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$var1= $_SESSION['NAME'];
$var2= $_SESSION['PASS'];
$previous=$newpass=$confirmpass="";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$previous = $_POST["oldpass"];
$newpass = $_POST["newpass"];
$confirmpass = $_POST["confpass"];
$sql = "SELECT DISTINCT * FROM donorreg WHERE Password = '$previous'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0)
{
if($newpass == $confirmpass)
{
$changepassword = "update donorreg set Password = '$newpass' where Password = '$previous' AND Name = '$var1'";
$execute = mysqli_query($conn, $changepassword);
//echo "<p>"."PASSWORD CHANGED SUCCESSFULLY!"."</p>";
header('Location:PassChanged.php');
}
else{
echo "<p>"."ERROR IN CHANGING PASSWORD"."</p>";
}
}
}
?>
</body>
</html>