1

This my android code I used to send to my php file in website. also modified android manifest file.

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7);
        nameValuePairs.add(new BasicNameValuePair("number", "5556"));
        nameValuePairs.add(new BasicNameValuePair("password",password));
        nameValuePairs.add(new BasicNameValuePair("token",token));

        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://futuretime.in/post.php");
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);

This is my php script for receiving data from android. But my problem is when I printed data in php it is not showing any value.

        <?php 
          $number= $_POST['number'];
          $password = $_POST['password'];
          $token   = $_POST['token'];
          echo $number;
        ?>
9
  • what is your question? are you getting any error? Commented Apr 2, 2014 at 5:36
  • What exact you want to do??? Commented Apr 2, 2014 at 5:36
  • You can send data by JSON parsing. Small reference is stackoverflow.com/a/22686616/3360307 Commented Apr 2, 2014 at 5:39
  • 1
    You cannot echo data in php while calling from client side, save that data somewhere when called from android and then see if it's received or not Commented Apr 2, 2014 at 5:41
  • if (!empty($_POST)) {$number= $_POST['number']; $password = $_POST['password']; $token = $_POST['token']; echo $number;}else{echo "Empty";} try this and check your post is empty or not. then you can identify where is the error. Commented Apr 2, 2014 at 5:47

1 Answer 1

1

you can try use Ion https://github.com/koush/ion ,is a great library for make http request. is a simple example .check the project site for more examples and wiki.

    Ion.with(getContext(), "https://koush.clockworkmod.com/test/echo")
   .setBodyParameter("goop", "noop")
   .setBodyParameter("foo", "bar")
   .asString()
   .setCallback(...)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.