<?php
require_once('db.php');
// Create connection 
$conn = new mysqli($servername, $username, $password, $dbname);
   $userPhone= trim($_POST["phone"]);
   $hasPass = trim($_POST["password"]);
   // check phone number
   $sql = "select * from user where email = '$userPhone'";
   $countUser = mysqli_query($conn, $sql);
   if(mysqli_num_rows($countUser) > 0) {
        $sql = "UPDATE user SET password = '$hasPass' WHERE email='$userPhone'";
        $run = mysqli_query($conn,$sql);
        mysqli_error($run);
        if($run==true){
        $res->success = 'success';
	    echo json_encode($res);
            // echo "success";
        }
        else{
            echo "Failed";
        }
   } else {
        $res->success = 'not matching';
	    echo json_encode($res);
    //   echo 'not matching';
       
   }

// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
// echo "Connected successfully";