Guest User

Untitled

a guest
Aug 2nd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. private void jsonParse() {
  2. String url = "http://178.128.166.68/getUserInfo.php";
  3.  
  4.  
  5. JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, null,
  6. new Response.Listener<JSONObject>() {
  7. @Override
  8. public void onResponse(JSONObject response) {
  9. try {
  10. JSONArray jsonArray = response.getJSONArray("profileData");
  11.  
  12. for (int i = 0; i < jsonArray.length(); i++) {
  13. JSONObject profileData = jsonArray.getJSONObject(i);
  14.  
  15. id = profileData.getString("id");
  16. fNameGet = profileData.getString("fName");
  17. lNameGet = profileData.getString("lName");
  18. phoneGet = profileData.getString("phone");
  19. joinedDateGet = profileData.getString("joined");
  20. noOfTripsGet = profileData.getString("noOfTrips");
  21.  
  22.  
  23. }
  24.  
  25. SharedPreferences settings = getSharedPreferences("myData", Context.MODE_PRIVATE);
  26. SharedPreferences.Editor editor = settings.edit();
  27. editor.putString("phone", phoneGet);
  28. editor.putString("fName", fNameGet);
  29. editor.putString("lName", lNameGet);
  30. editor.putString("joined", joinedDateGet);
  31. editor.putString("Trips", noOfTripsGet);
  32.  
  33. editor.commit();
  34.  
  35.  
  36. } catch (JSONException e) {
  37. e.printStackTrace();
  38. }
  39. }
  40. }, new Response.ErrorListener() {
  41. @Override
  42. public void onErrorResponse(VolleyError error) {
  43. error.printStackTrace();
  44. }
  45. }) {
  46. @Override
  47. protected Map<String, String> getParams() {
  48. Map<String, String> params = new HashMap<String, String>();
  49. params.put("user_name", username);
  50. params.put("password", password);
  51.  
  52. return params;
  53. }
  54.  
  55. };
  56.  
  57. mQueue.add(request);
  58. Toast.makeText(this, id + fNameGet + lNameGet, Toast.LENGTH_LONG).show();
  59. }
  60. }
  61.  
  62. $username = $_POST["user_name"];
  63. $pass = $_POST["password"];
  64.  
  65.  
  66. $qry = "select * from user where phone like '$username' and pass = '$pass';";
  67.  
  68. $result = mysqli_query($conn, $query) or die (mysqli_error($conn));
  69.  
  70. $rows=array();
  71.  
  72. while($row = mysqli_fetch_array($result)) {
  73. $rows[] = $row;
  74. }
  75.  
  76. echo json_encode(array('profileData' =>$rows));
  77.  
  78.  
  79. mysqli_close($conn);
  80. ?>
Add Comment
Please, Sign In to add comment