-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings_script.php
31 lines (30 loc) · 977 Bytes
/
settings_script.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
<?php
include('common.php');
$oldpassword=filter_input(INPUT_POST,'oldpassword');
$oldpassword=md5($oldpassword);
$newpassword=filter_input(INPUT_POST,'newpassword');
$confirmpassword=filter_input(INPUT_POST,'confirmpassword');
$id=$_SESSION['id'];
$query="select password from users where id=$id";
$result= mysqli_query($conn, $query);
$row= mysqli_fetch_array($result);
$stored_password=$row['password'];
if(strcmp($oldpassword,$stored_password)!=0)
{
echo "<script>location='settings.php?olderror=Wrong Password!'</script>";
}
else
{
if(strcmp($newpassword,$confirmpassword)==0)
{
$newpassword=md5($newpassword);
$query="update users set password='$newpassword' where id=$id";
$result=mysqli_query($conn, $query);
echo "<script>location='settings.php?success=Password Changed Successfully!'</script>";
}
else
{
echo "<script>location='settings.php?confirmerror=Passwords don't match'</script>";
}
}
?>