Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void jsonParse() {
- String url = "http://178.128.166.68/getUserInfo.php";
- JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, null,
- new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject response) {
- try {
- JSONArray jsonArray = response.getJSONArray("profileData");
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject profileData = jsonArray.getJSONObject(i);
- id = profileData.getString("id");
- fNameGet = profileData.getString("fName");
- lNameGet = profileData.getString("lName");
- phoneGet = profileData.getString("phone");
- joinedDateGet = profileData.getString("joined");
- noOfTripsGet = profileData.getString("noOfTrips");
- }
- SharedPreferences settings = getSharedPreferences("myData", Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = settings.edit();
- editor.putString("phone", phoneGet);
- editor.putString("fName", fNameGet);
- editor.putString("lName", lNameGet);
- editor.putString("joined", joinedDateGet);
- editor.putString("Trips", noOfTripsGet);
- editor.commit();
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- error.printStackTrace();
- }
- }) {
- @Override
- protected Map<String, String> getParams() {
- Map<String, String> params = new HashMap<String, String>();
- params.put("user_name", username);
- params.put("password", password);
- return params;
- }
- };
- mQueue.add(request);
- Toast.makeText(this, id + fNameGet + lNameGet, Toast.LENGTH_LONG).show();
- }
- }
- $username = $_POST["user_name"];
- $pass = $_POST["password"];
- $qry = "select * from user where phone like '$username' and pass = '$pass';";
- $result = mysqli_query($conn, $query) or die (mysqli_error($conn));
- $rows=array();
- while($row = mysqli_fetch_array($result)) {
- $rows[] = $row;
- }
- echo json_encode(array('profileData' =>$rows));
- mysqli_close($conn);
- ?>
Add Comment
Please, Sign In to add comment