1

我有一个奇怪的问题,不知道为什么会这样。实际上,我在 PHP 中有一个非常简单的登录 API,它在 where 子句用户名和密码中采用 2 个参数并搜索特定结果。我正在使用 Android Volley 库来处理发布请求。一切都很完美,因为我认为我发送了一个 POST 请求并且我的 API 返回 JSON 数据。现在奇怪的是,整个过程运行顺利,就像在我所有的安卓设备上一样,但我的客户在英国,当他尝试登录时,我的 php 代码出人意料地返回没有找到记录!!!

这是我的 PHP 脚本:

function ShowDriverRecord($userName, $password) {
    global $connect;
    $query = "SELECT drv_id,drv_firstname,drv_surname FROM wp_booking_drivers WHERE drv_username = '$userName' AND drv_password = '$password'";
    $result = mysqli_query($connect,$query);
    $no_of_rows = mysqli_num_rows($result);

    $status = false;
    $driverId = null;
    $driverName = null;

    if ($no_of_rows > 0) {
        $driverRecord = mysqli_fetch_assoc($result);
        $status = true;
        $driverId = $driverRecord['drv_id'];
        $driverName = $driverRecord['drv_firstname']." ".$driverRecord['drv_surname'];
    }

    header('Content-Type: application/json');
    echo json_encode(array("Status"=>$status,"DriverId"=>$driverId,"DriverName"=>$driverName));
}

Java(Android Volley):

 Map<String,String> params = new HashMap<>();
    params.put("userName",username);
    params.put("password",password);
    CustomJsonRequest jsonRequest = new CustomJsonRequest(Request.Method.POST, WebUrls.DRIVER_LOGIN_URL, params, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            try {
                boolean status = response.getBoolean("Status");
                if (status){
                    callbacks.onSuccess(response);
                }else {
                    callbacks.onFailure("Wrong username or password.");
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
        error.printStackTrace();
    }
});
requestQueue.add(jsonRequest);

我在 123-reg.com 上有虚拟主机-请告诉我那里发生了什么?我在巴基斯坦,当我尝试登录时它可以工作,但是当我在英国的客户尝试使用相同的凭据登录时,它发现没有记录......谢谢。

4

0 回答 0