<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,DELETE,REQUEST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");

include 'config.php';
date_default_timezone_set("Africa/Lagos");
$date_t = date("d-M-Y h:i:s");
$today = date("d-m-Y");
$time = date("d-M-Y-h:i:s");

if(isset($_POST['user_id']) && isset($_POST['auth']))
{


function check_input($par){
  $par = trim($par);
  $par = stripslashes($par);
  $par = htmlspecialchars($par);
  return $par;
}

$user_id     =  check_input($_POST['user_id']);
$auth      =  check_input($_POST['auth']);
//$lng      =  check_input($_POST['lng']);
$user_id  = mysqli_real_escape_string($con, $user_id);
$auth   = mysqli_real_escape_string($con, $auth);
//$lng   = mysqli_real_escape_string($con, $lng);

$phone   =  check_input($_POST['phone']);
$phone   = mysqli_real_escape_string($con, $phone);




if(empty($user_id))
{
    $status = false;
    $msg = "User Not Defined";
}
else if(empty($phone))
{
    $status = false;
    $msg  ="Phone Number is Empty";
}



else{
      
$sqlx="UPDATE users SET phone = '$phone' WHERE user_id = '$user_id' AND auth = '$auth'";
$resultx=$con->query($sqlx) or die ("error2: Server error ".mysqli_error($con));

 
 if($sqlx)
 {
 
 
       $status = true;
        $msg = "Successful";
 }
 else{
     
     
     $status = false;
     $msg = "Failed to Update";
 }

}




 $output = array('status'=>$status, 'success'=>$msg);
 echo json_encode($output); //output JSON data

}
?>