<?php 
ob_start();
session_start();
include("include/connection.php");

// print_r($_POST);
//  print_r($_SESSION);

$password=mysqli_real_escape_string($con,$_POST['password']);
$oldpassword=mysqli_real_escape_string($con,$_POST['oldpassword']);
$mobile=mysqli_real_escape_string($con,$_POST['mobile']);

$sqlp = mysqli_fetch_assoc(mysqli_query($con,"select show_password from tbl_user where mobile='$mobile'"));


if($_POST['oldpassword'] == $sqlp['show_password'])
{

   //print_r('succes');exit;
  $password=mysqli_real_escape_string($con,md5($_POST['password']));
  $show_password=mysqli_real_escape_string($con,$_POST['password']);
   $sql = "UPDATE tbl_user SET password='$password',show_password='$show_password' WHERE mobile='$mobile'";
      $select=mysqli_query($con,$sql)or die(mysqli_error($con));
      echo "<script type='text/javascript'>alert('Successfully Update'); window.location='login';</script>";

}else{
    echo "<script type='text/javascript'>alert('Old Password Wrong'); window.location='forgot-password';</script>";
}	
	 
          
          
?>