title: Posting Data from an android application to MySql database
body: <p>I'am creating a simple application in android which sends data from a form to a mysql database   by php and by using httppost function here is my code in java</p>
  
  <pre><code> public class NouvelUtilisateur extends Activity
  {
      EditText username,password,name,lastname,phone,adresse ;
      Button bouton ;
      HttpPost httppost;
      StringBuffer buffer;
      HttpClient httpclient ;
  
  
  
      @Override
   public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.nouveau);
  
   username = (EditText)  findViewById(R.id.id1) ;
   password = (EditText) findViewById(R.id.pwd);
   name = (EditText) findViewById(R.id.name);
   lastname = (EditText)  findViewById(R.id.Lastname);
   phone = (EditText) findViewById(R.id.phone);
   adresse = (EditText) findViewById(R.id.adress);
   bouton = (Button) findViewById(R.id.button3) ;
  
   final String id1 = username.getText().toString();
   final String mdp = password.getText().toString();
   final String prenom = name.getText().toString();
   final String nom = lastname.getText().toString();
   final String tel = phone.getText().toString();
   final String adresse1 = adresse.getText().toString();
  
  
  
  
   bouton.setOnClickListener(new View.OnClickListener()
   {
       public void onClick(View nouveau)
  
       {
  
                    try {
                        httpclient = new DefaultHttpClient();
                        httppost = new HttpPost("http://192.168.1.110/nouveau.php");
                        ArrayList&lt;NameValuePair&gt; postParameters = new ArrayList&lt;NameValuePair&gt;();
                     postParameters.add(new BasicNameValuePair("Username", id1));
                     postParameters.add(new BasicNameValuePair("Password", mdp));
                     postParameters.add(new BasicNameValuePair("Name", prenom));
                     postParameters.add(new BasicNameValuePair("Lastname", nom));
                     postParameters.add(new BasicNameValuePair("Phone", tel));
                     postParameters.add(new BasicNameValuePair("Adresse", adresse1));
                     httppost.setEntity(new UrlEncodedFormEntity(postParameters));                   
                     HttpResponse response = httpclient.execute(httppost);
                     Log.i("postData", response.getStatusLine().toString());
                         }
                         catch(Exception e)
                         {
                             Log.e("log_tag", "Error:  "+e.toString());
                         }  
                       }
                   });
               }
           }
  </code></pre>
  
  <p>and here is my php code </p>
  
  <pre><code> &lt;?php 
  mysql_connect("localhost","root","") or die(mysql_error());
  mysql_select_db("agenceimmo");
  $username =   $_POST['Username'];
  $password = $_POST['Password'] ;
  $nom = $_POST['Lastname'] ;
  $prenom = $_POST['Name'] ;
  $tel = $_POST['Phone'] ; 
  $adresse = $_POST['Adresse'] ;
  $query_add="INSERT INTO  clients (`id` ,`password` ,`nom` ,`prenom` ,`tel` ,`adresse`)
  VALUES ('.$username','.$password', '.$nom','.$prenom','.$tel','.$adresse')";
  $query_exec=mysql_query($query_add) or die(mysql_error()); 
  mysql_close()
  ?&gt;
  </code></pre>
  
  <p>I really need your help please i can't see any errors</p>