-
Notifications
You must be signed in to change notification settings - Fork 1
/
sett.php
37 lines (33 loc) · 965 Bytes
/
sett.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
<?php
$con=mysqli_connect("localhost:3308","root","","ecommerce1") or die(mysqli_error($con));
session_start();
$old_password=mysqli_real_escape_string($con, $_POST['old-pwd']);
$new_password=mysqli_real_escape_string($con, $_POST['new-pwd']);
$re_password=mysqli_real_escape_string($con, $_POST['re-pwd']);
$old_pass=md5($old_password);
$new_pass=md5($new_password);
$re_pass=md5($re_password);
$user_id= $_SESSION['id'];
$user_pass= $_SESSION['password'];
if($old_pass == $user_pass)
{
if($new_pass == $re_pass)
{
$update_query="update users set password = '$new_pass' where id = '$user_id'";
$update_result=mysqli_query($con, $update_query) or die(mysqli_error($con));
$_SESSION['password']= $new_pass;
echo "Password Updated Successfully<br>";
?>
<a href="index.php"><b>Continue to Shopping.</b></a>
<?php
}
else
{
echo "Re-Entered password didn't match the newly entered password.";
}
}
else
{
echo "Old Password entered is wrong.";
}
?>