-
Notifications
You must be signed in to change notification settings - Fork 0
/
setting_script.php
31 lines (31 loc) · 1.23 KB
/
setting_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
session_start();
require 'connection.php';
if(!isset($_SESSION['email'])){
header('location:index.php');
}
$old_password= md5(md5(mysqli_real_escape_string($con,$_POST['oldPassword'])));
$new_password= md5(md5(mysqli_real_escape_string($con,$_POST['newPassword'])));
$email=$_SESSION['email'];
//echo $email;
$password_from_database_query="select password from users where email='$email'";
$password_from_database_result=mysqli_query($con,$password_from_database_query) or die(mysqli_error($con));
$row=mysqli_fetch_array($password_from_database_result);
//echo $row['password'];
if($row['password']==$old_password){
$update_password_query="update users set password='$new_password' where email='$email'";
$update_password_result=mysqli_query($con,$update_password_query) or die(mysqli_error($con));
echo "Your password has been updated.";
?>
<meta http-equiv="refresh" content="3;url=products.php" />
<?php
}else{
?>
<script>
window.alert("Wrong password!!");
</script>
<meta http-equiv="refresh" content="1;url=settings.php" />
<?php
//header('location:settings.php');
}
?>