I am trying to do a POST request from Android to insert some information in my phpmyadmin. 
What I am using
- Slimto make the connection and the query with the database stored at phpmyadmin.
- XAMPP to simulate a local server.
- Volley to consume the requests from Android.
The Slim post function is not giving any problems to me because if I use it with POST mode on Postman application the data is being inserted properly on the database. 
The url can accept two parameters separated by slash /. Here one example:
http://localhost:8000/insert/Peter/25
in which I insert a new user with name Peter and age of 25 in the database.
The problems come when I try to call the same url from Android using Volley because it always goes to onErrorResponse method.
This is the code that I have to consume the request from Android:
RequestQueue queue = Volley.newRequestQueue(getContext());
String url = "http://localhost:8000/insert/" + name + "/" + age;
StringRequest postRequest = new StringRequest(Request.Method.POST, url,
     new Response.Listener<String>()
     {
         @Override
         public void onResponse(String response) {
            Log.d("Response", "works well");
         }
     },
     new Response.ErrorListener()
     {
         @Override
         public void onErrorResponse(VolleyError error) {
            Log.d("Response", "" + error.getMessage());
         }
     }
);
queue.add(postRequest);
But it always goes to the onErrorResponse method.
What I have checked
- That the computer in which I have the XAMPP running is on the same WIFI than the smartphone.
- That changing localhost for the IP of my computer also does not change the result.
UPDATE:
I have noticed that I was using the IP of Ethernet adapter instead of WIFI on the url.
Now I can see on smartphone browser XAMPP default webpage if I set http://192.168.x.x (IP of my WIFI) on the url but I still have the problem that I mentioned above because if I set http://192.168.x.x:8000/insert/Peter/25 the url is not recognised by the smartphone.
I think that the problem could be because I use the built-in PHP server as Slim documentation suggests. I use the following command:
php -S localhost:8000
so I think that the problem can be generated here but I am not sure how to solve it.
What am I missing?
Thanks in advance!
 
     
     
    