For working on the localhost use and for remote use the IP or domain name of the server.
The following code does this.

package com.pack;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import android.os.Bundle;
import android.widget.Toast;

public class active extends Activity
    HttpPost httpPost;
    ResponseHandler response;
    String result;
    HttpClient htClient;

    public void onCreate(Bundle savedInstanceState)

        Toast.makeText(active.this,"Accessing.....", Toast.LENGTH_SHORT).show();

        htClient = new DefaultHttpClient();
        httpPost = new HttpPost("");
 response = new BasicResponseHandler();
 result = htClient.execute(httpPost,response);
 Toast.makeText(active.this,result, Toast.LENGTH_SHORT).show();
 catch (ClientProtocolException e) {

 Toast.makeText(active.this,e.getMessage(), Toast.LENGTH_SHORT).show();
 catch (IOException e) {
 Toast.makeText(active.this,"IO Error " + e.getMessage(), Toast.LENGTH_LONG).show();


  1. June 15, 2011 at 11:15 am

    interesting blog . It would be great if you can offer more contingents about it. Thanks you.

  2. Simple PHP June 22, 2011 at 12:26 am

    You’ve got great insights about PHP systems, keep up the good work!

  3. ERNESTO December 27, 2011 at 2:46 pm

    how can i post a string from android to a server using php ?!


Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.