Android will not send data to PHP using JSON


I am trying create an android app that can send data to a PHP server using JSON. I followed this guide: and here is my Android code:

import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class HelloWorldActivity extends Activity {

    JSONParser jsonParser = new JSONParser();
    EditText userName;

    // url to create new product
    private static String url = "";    

    public void onCreate(Bundle savedInstanceState) {

        // Edit Text
        userName = (EditText) findViewById(;

        // Send button
        Button sendButton = (Button) findViewById(;

        // button click event
        sendButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                String name = userName.getText().toString();

                // Building Parameters
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("name", name));

                // getting JSON Object
                JSONObject json = jsonParser.makeHttpRequest(url, "POST", params);



As for my PHP code:

  function insert($var1) {

    // mysql inserting a new row
    $result = mysql_query("INSERT INTO report (name) VALUES ('$var1')");

    // check if row inserted or not
    if ($result) {
        // successfully inserted into database;
    $msg = "Message received.";
    } else {
    $msg = "Not received.";
return ($msg);

if (isset($_POST['name'])) {
   $name = $_POST['name']);
} else {
   echo "No input.";

I keep getting No input. I run the android app (on my phone connected to the computer), then I refresh the PHP site but I keep getting no input. The android app does not send the data. Can someone pls help? THANK YOU VERY MUCH!

From what I see, it's the JSONParser class of the tutorial. It checks for

method == "POST"

which is wrong. Change this to


and see if it works.