<?php
require 'db.php';
header( 'Content-Type: text/html; charset=utf-8' ); 
$data = json_decode(file_get_contents('php://input'), true);

$pin = $data['phone'];
$password = $data['password'];
if ($pin =='' or $password =='' || $data['shop_id'] =='')
{
    $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Something Went wrong try again!");
}
else 
{
    $pin = strip_tags(mysqli_real_escape_string($con,$pin));
    $password = strip_tags(mysqli_real_escape_string($con,$password));
    $shop_id = strip_tags(mysqli_real_escape_string($con,$data['shop_id']));
    $shop_code = strip_tags(mysqli_real_escape_string($con,$data['shop_code']));
    
    $counter = $con->query("select * from user where mobile='$pin' and shop_id = '$shop_id' and shop_code = '$shop_code'");
    
    if($counter->num_rows != 0)
    {
        $con->query("update user set password='$password' where mobile='$pin' and shop_id = '$shop_id' and shop_code = '$shop_code'");
        $returnArr = array("ResponseCode"=>"200","Result"=>"true","ResponseMsg"=>"Password Changed Successfully!");    
    }
    else
    {
        $returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Mobile Not Registered!");  
    }
}

echo json_encode($returnArr);
?>