title: Inserting Data From Android to PHP file and then to Mysql error
body: <p>I'm inserting data into a mysql database with a function in my android app but it crashes every time I click the button to execute it. These are the errors I get:</p>
  
  <p>10-08 16:16:05.649: E/AndroidRuntime(19038): FATAL EXCEPTION: main
  10-08 16:16:05.649: E/AndroidRuntime(19038): android.os.NetworkOnMainThreadException
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1125)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at java.net.InetAddress.getAllByName(InetAddress.java:214)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at com.example.gloc.MainActivity.insert(MainActivity.java:360)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at com.example.gloc.MainActivity$3.onClick(MainActivity.java:217)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at android.view.View.performClick(View.java:4354)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at android.view.View$PerformClick.run(View.java:17961)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at android.os.Handler.handleCallback(Handler.java:725)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at android.os.Handler.dispatchMessage(Handler.java:92)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at android.os.Looper.loop(Looper.java:137)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at android.app.ActivityThread.main(ActivityThread.java:5328)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at java.lang.reflect.Method.invokeNative(Native Method)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at java.lang.reflect.Method.invoke(Method.java:511)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
  10-08 16:16:05.649: E/AndroidRuntime(19038):    at dalvik.system.NativeStart.main(Native Method)</p>
  
  <p>this is my code</p>
  
  <pre><code>public void insert(){  
      String input_data= "http://www.wolfdoginfo.net/app/dataapp.php"; //URL website anda dengan file insert.php yang telah dibuat  
  
        HttpClient httpClient = new DefaultHttpClient();  
        HttpPost httpPost = new HttpPost(input_data);  
        ArrayList&lt;NameValuePair&gt; param = new ArrayList&lt;NameValuePair&gt;();  
      final EditText reguser = (EditText) findViewById(R.id.usernamecomplete);
      final EditText regpass = (EditText) findViewById(R.id.passwordcomplete);
      final EditText regemail = (EditText) findViewById(R.id.email);
      String password = regpass.getText().toString();
      password =  md5(password);
        param.add(new BasicNameValuePair("username", reguser.getText().toString()));  
        param.add(new BasicNameValuePair("password", password));  
        param.add(new BasicNameValuePair("email", regemail.getText().toString())); 
  
        try {  
             httpPost.setEntity(new UrlEncodedFormEntity(param));  
             HttpResponse httpRespose = httpClient.execute(httpPost);  
            HttpEntity httpEntity = httpRespose.getEntity();  
            InputStream in = httpEntity.getContent();  
            BufferedReader read = new BufferedReader(new InputStreamReader(in));  
  
            String isi= "";  
            String baris= "";  
  
            while((baris = read.readLine())!=null){  
               isi+= baris;  
            }  
  
            //Jika isi tidak sama dengan "null " maka akan tampil Toast "Berhasil" sebaliknya akan tampil "Gagal"  
            if(!isi.equals("null")){                    
               Toast.makeText(this, "Berhasil", Toast.LENGTH_LONG).show();  
            }else{  
               Toast.makeText(this, "Gagal", Toast.LENGTH_LONG).show();  
            }  
  
      } catch (ClientProtocolException e) {  
         // TODO Auto-generated catch block  
         e.printStackTrace();  
      } catch (IOException e) {  
         // TODO Auto-generated catch block  
         e.printStackTrace();  
      }  
  </code></pre>
  
  <p>}        </p>