title: Insert data into MySQL database from Android app. Changes not reflected in database
body: <p>I'm writing an application to insert data into a MySQL database. I wrote the sql query in PHP and when I enter values in the android application, I don't seen any errors in the log cat but the values aren't getting stored in the database. </p>
  
  <p>Here's the PHP code:</p>
  
  <pre><code>&lt;?php
  
  $connect = mysqli_connect("localhost","root","","easyassigndroid");
  
  if(mysqli_connect_errno($connect))
  {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  else
  {
      echo "success";
  }
  
  $username = isset($_POST['sPhone']) ? $_POST['sPhone'] : '';
  $password = isset($_POST['sPassword']) ? $_POST['sPassword'] : '';
  
  $query = mysqli_query($connect, "insert into users (sphone, spassword) values ('$username' ,'$password') ");
  
  mysqli_close($connect);
  ?&gt;
  </code></pre>
  
  <p>Here's the android part:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
  
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.register_lecturer);
  
      phonenum = (EditText) findViewById(R.id.id_phone);
      password = (EditText) findViewById(R.id.id_password);
  
      sPhone = phonenum.toString();
      sPassword = password.toString();
  
      registerLecturer=(Button)findViewById(R.id.lecturerregister);
      registerLecturer.setOnClickListener(new View.OnClickListener() {
  
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
              httpclient = new DefaultHttpClient();
              httppost = new HttpPost("http://10.0.2.2/project/insert.php");
  
              try
              {
                  nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
                  nameValuePairs.add(new BasicNameValuePair("sphone", sPhone));
                  nameValuePairs.add(new BasicNameValuePair("spassword", sPassword));
  
                  httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                  response = httpclient.execute(httppost);
              }
              catch(Exception e)
              {
                  e.printStackTrace();
              }
          }
      });
  
  
  }
  </code></pre>
  
  <p>I'm a beginner to both Android and PHP coding. Can anyone tell me where the problem is in my code? I need this for my project work. </p>