Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. function ShowDriverRecord($userName, $password) {
  2. global $connect;
  3. $query = "SELECT drv_id,drv_firstname,drv_surname FROM wp_booking_drivers WHERE drv_username = '$userName' AND drv_password = '$password'";
  4. $result = mysqli_query($connect,$query);
  5. $no_of_rows = mysqli_num_rows($result);
  6.  
  7. $status = false;
  8. $driverId = null;
  9. $driverName = null;
  10.  
  11. if ($no_of_rows > 0) {
  12. $driverRecord = mysqli_fetch_assoc($result);
  13. $status = true;
  14. $driverId = $driverRecord['drv_id'];
  15. $driverName = $driverRecord['drv_firstname']." ".$driverRecord['drv_surname'];
  16. }
  17.  
  18. header('Content-Type: application/json');
  19. echo json_encode(array("Status"=>$status,"DriverId"=>$driverId,"DriverName"=>$driverName));
  20.  
  21. Map<String,String> params = new HashMap<>();
  22. params.put("userName",username);
  23. params.put("password",password);
  24. CustomJsonRequest jsonRequest = new CustomJsonRequest(Request.Method.POST, WebUrls.DRIVER_LOGIN_URL, params, new Response.Listener<JSONObject>() {
  25. @Override
  26. public void onResponse(JSONObject response) {
  27. try {
  28. boolean status = response.getBoolean("Status");
  29. if (status){
  30. callbacks.onSuccess(response);
  31. }else {
  32. callbacks.onFailure("Wrong username or password.");
  33. }
  34. } catch (JSONException e) {
  35. e.printStackTrace();
  36. }
  37. }
  38. }, new Response.ErrorListener() {
  39. @Override
  40. public void onErrorResponse(VolleyError error) {
  41. error.printStackTrace();
  42. }
  43. });
  44. requestQueue.add(jsonRequest);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement