-
Notifications
You must be signed in to change notification settings - Fork 12
/
settings_script.php
33 lines (32 loc) · 1.11 KB
/
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
32
33
<?php
require("includes/common.php");
if (!isset($_SESSION['email']))
{
header('location: index.php');
}
$oldpassword=mysqli_real_escape_string($con,$_POST['oldpassword']);
$password=mysqli_real_escape_string($con,$_POST['password']);
$password1=mysqli_real_escape_string($con,$_POST['password1']);
$check=strcmp($password,$password1);
if($check==0)
{
$email=$_SESSION['email'];
$select_query="SELECT id,email,password FROM users WHERE email='$email' AND password='$oldpassword' ";
$select_query_result=mysqli_query($con,$select_query) or die(mysqli_error($con));
$row_num=mysqli_num_rows($select_query_result);
if($row_num==0)
{
header('location: settings.php');
}
else
{
$select_query="UPDATE users SET password='$password' WHERE email='$email' AND password='$oldpassword' ";
$select_query_result=mysqli_query($con,$select_query) or die(mysqli_error($con));
header('location: products.php');
}
}
else
{
echo "The two new passwords entered do not match! Please go back and try again.";
}
?>