Stagleton
Stagleton

Reputation: 1060

How do I send data in a url to test a php file?

I am trying to see what is wrong with a php script a wrote. The script is getting information from an android application and then using that data to search a table and send information back. The client side is written like this:

    nameValuePairs.add(new BasicNameValuePair("num1", num1));
    nameValuePairs.add(new BasicNameValuePair("num2", num2));
    nameValuePairs.add(new BasicNameValuePair("num3", num3));
    nameValuePairs.add(new BasicNameValuePair("num4", num4));


    InputStream is = null;

        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://10.0.0.4/xampp/phpfile.php");
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();

How do I format the url in a browser if I want to execute the same script passing num1, num2, num3 and num4 in the same way?

Upvotes: 0

Views: 2304

Answers (2)

Rahul garg
Rahul garg

Reputation: 9362

use http://hurl.it/ to test POST request from your browser...

Upvotes: 2

Ernest Marcinko
Ernest Marcinko

Reputation: 405

Since you are using POST methos, as I can see, you can't call it from a browser url. You can write a simple html file, with a form in it, wich uses post method, and then submit that. Or modify the server side php file, and instead of using $_POST[] variables use $_REQUEST[] variables, wich accept both GET and POST method calls. In this case: http://10.0.0.4/xampp/phpfile.php?num1=num1&num2=num2... should work fine.

Upvotes: 1

Related Questions