<?php	

	if(isset($_GET['phoneNumber'])){
	
		require_once "connection.php";
	
	
		$phoneNumber = $_GET['phoneNumber'];

    $firstChar = substr($phoneNumber, 0, 1);

 if($firstChar == '0'){
    $phoneReal = $phoneNumber;   
} else {
    $phoneReal = '0' . $phoneNumber;
}

		$sql = "select tokenHp from nasabah where phoneNumber='$phoneReal'";
	
		 if(!$con->query($sql)){
        echo "Error in executing query.";
            }else{
                $result = $con->query($sql);
                 if($result->num_rows > 0){
                       $return_arr['kodeOTP'] = array();
                      while($row = $result->fetch_array()){
                       array_push($return_arr['kodeOTP'], array(
                    'tokenHp'=>$row['tokenHp']
                ));
            }
            echo json_encode($return_arr);
        }
    }
	}
	?>