-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathchangePasswordNew.php
51 lines (45 loc) · 1.17 KB
/
changePasswordNew.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
<?php
include('pass.php');
include('session.php');
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_POST['oldpassword'])!=null&&isset($_POST['newpassword1'])!=null)
{
$old=md5($_POST['oldpassword']);
$new=md5($_POST['newpassword1']);
$found=-1;
//echo $old."<br>".$new."<br/>".$user_check;
$sql="SELECT * FROM alumni where `email`='$user_check' AND `password`='$old'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
//echo $row["id"];
$found=$row["id"];
/**/
}
}
if($found!=-1)
{
$sql = "UPDATE `alumni` SET `password`='$new' WHERE `id`='$found'";
if ($conn->query($sql) === TRUE) {
//echo "Record updated successfully";
header("location: user.php?message=passChanged");
} else {
//echo "Error updating record: " . $conn->error;
header("location: user.php?message=passChangeError");
}
}
else {
header("location: user.php?message=passChangeError");
}
}
else
{
header("location: user.php?message=passChangeError");
}
$conn->close();
?>