Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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));
- }
- 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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement