<?php
include("../commonpages/dbconnect.php");
if(isset($_POST['change']))
{
	 $old=$_POST['old'];
	 $new=$_POST['new'];
	 $confirm=$_POST['confirm'];
	 $id=$_POST['id'];
	 /* Database Code */
	 
	 
 echo  $sql="SELECT * FROM user_registration WHERE password='$old' AND id=$id";
	 $data=mysqli_query($con,$sql);
	 if(mysqli_num_rows($data)>0)
	 {
				if($new==$confirm){
				  echo $sql_update="UPDATE user_registration SET password='$new' WHERE id=$id";
				  $data_pass=mysqli_query($con,$sql_update);
				  header('Location:../edit-profile-password.php?SUCCESSFULLY_CHANGED_PASSWORD');
				}	
			   else{
				   //echo "no";
				   header('Location:../edit-profile-password.php?CONFIRM_PASSWORD_DOSENOT_MATCH');
			   }	   
	 }
	else{
           header('Location:../edit-profile-password.php?WRONG_OLD_PASSWORD');
	 }	   
}
?>

