title: how to connect phpmyadmin database with android application
body: <p>I have asked this question before but that time i didn't have php file, now i have created php files and saved it on my xampp folder and its working i have checked it, the problem is in the code somewhere. I am trying to link my android studio register page with database but its not working. when user enters their details it should automatically save it on the database that I've created on phpmyadmin but when i click register on the app nothing happens. I am going to past the code below, please can anybody tell me wheres the problem?
  thanks</p>
  
  <p>this is my register java class </p>
  
  <pre><code>ublic class Register extends Activity {
  
  EditText ET_FIRST_NAME, ET_LAST_NAME, ET_ADDRESS, ET_EMAIL, ET_PASSWORD;
  String first_name,last_name,address,email,password;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_register);
  
      ET_FIRST_NAME = (EditText)findViewById(R.id.etFname);
      ET_LAST_NAME = (EditText)findViewById(R.id.etLname);
      ET_ADDRESS = (EditText)findViewById(R.id.etAddress);
      ET_EMAIL = (EditText)findViewById(R.id.etEmail);
      ET_PASSWORD = (EditText)findViewById(R.id.etPassword);
  }
  
  public void btRegister(View view)
  {
      first_name =  ET_FIRST_NAME.getText().toString();
      last_name = ET_LAST_NAME.getText().toString();
      address = ET_ADDRESS.getText().toString();
      email = ET_EMAIL.getText().toString();
      password = ET_PASSWORD.getText().toString();
  
      String method = "register";
      BackgroundTask backgroundTask = new BackgroundTask(this);
      backgroundTask.execute(method, first_name,last_name,address,email,password);
      finish();
  }
  }
  </code></pre>
  
  <p>this is the activity </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:orientation="vertical"
  android:layout_height="match_parent"
  android:padding="15dp"
  android:layout_width="match_parent"
  android:background="#8a73d5"&gt;
  
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Register Form"
      android:textAppearance="?android:textAppearanceLarge"
      android:textStyle="bold"
      android:layout_gravity="center_horizontal"
      android:layout_marginTop="2dp"
      /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:text="First Name"
      android:layout_height="wrap_content"
      android:textColor="#000000" /&gt;
  
  &lt;EditText
      android:id="@+id/etFname"
      android:layout_width="match_parent"
  
      android:layout_height="wrap_content"
       /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:text="Last Name"
      android:layout_height="wrap_content"
      android:textColor="#000000"
      android:background="#8a73d5" /&gt;
  
  &lt;EditText
      android:id="@+id/etLname"
      android:layout_width="match_parent"
      android:layout_marginBottom="1dp"
      android:layout_height="wrap_content"
       /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:text="Address"
      android:layout_height="wrap_content"
      android:textColor="#000000" /&gt;
  
  &lt;EditText
      android:id="@+id/etAddress"
      android:layout_width="match_parent"
      android:layout_marginBottom="1dp"
      android:layout_height="wrap_content"
      /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:text="Email"
      android:layout_height="wrap_content"
      android:textColor="#000000" /&gt;
  
  &lt;EditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:inputType="textEmailAddress"
      android:id="@+id/etEmail"
       /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:text="Password"
      android:layout_height="wrap_content"
      android:textColor="#000000" /&gt;
  
  &lt;EditText
      android:id="@+id/etPassword"
      android:layout_width="match_parent"
      android:layout_marginBottom="1dp"
      android:inputType="textPassword"
      android:layout_height="wrap_content"
       /&gt;
  
  
  &lt;Button
      android:id="@+id/btRegister"
      android:text="Register"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>and this is the background task class where the all code is for saving info(login and register) to database. </p>
  
  <pre><code>public class BackgroundTask extends AsyncTask &lt;String, Void, String&gt; {
  AlertDialog alertDialog;
  Context ctx;
  
  BackgroundTask(Context ctx){
  
      this.ctx = ctx;
  }
  @Override
  protected void onPreExecute() {
  
      alertDialog = new AlertDialog.Builder(ctx).create();
      alertDialog.setTitle("Login Infomration");
  }
  
  @Override
  protected String doInBackground(String... params) {
     String reg_url = "http://192.168.0.10/webapp/register.php";
      String login_url = "http://192.168.0.10/webapp/login.php";
      String method = params [0];
      if (method.equals("register") ){
          String first_name = params [1];
          String last_name = params [2];
          String address = params [3];
          String email = params [4];
          String password = params [5];
          try {
              URL url = new URL(reg_url);
              HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
              httpURLConnection.setRequestMethod("POST");
              httpURLConnection.setDoOutput(true);
              OutputStream OS = httpURLConnection.getOutputStream();
              BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(OS, "UTF-8"));
  
              String data = URLEncoder.encode("first_name", "UTF-8") + "=" + URLEncoder.encode(first_name, "UTF-8") + "&amp;" +
                      URLEncoder.encode("last_name", "UTF-8") + "=" + URLEncoder.encode(last_name, "UTF-8") + "&amp;" +
                      URLEncoder.encode("address", "UTF-8") + "=" + URLEncoder.encode(address, "UTF-8")+ "&amp;" +
                      URLEncoder.encode("email", "UTF-8") + "=" + URLEncoder.encode(email, "UTF-8")+ "&amp;" +
                      URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8");
              bufferedWriter.write(data);
              bufferedWriter.flush();
              bufferedWriter.close();
              OS.close();
              InputStream IS = httpURLConnection.getInputStream();
              IS.close();
              httpURLConnection.disconnect();
              return "Registration Has Been Successful.";
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
      else if(method.equals("login"))
      {
          String login_name = params[1];
          String login_pass = params[2];
          try {
              URL url = new URL(login_url);
              HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
              httpURLConnection.setRequestMethod("POST");
              httpURLConnection.setDoOutput(true);
              httpURLConnection.setDoInput(true);
              OutputStream outputStream = httpURLConnection.getOutputStream();
              BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream,"UTF-8"));
              String data = URLEncoder.encode("login_name","UTF-8")+"="+URLEncoder.encode(login_name,"UTF-8")+"&amp;"+
                      URLEncoder.encode("login_pass","UTF-8")+"="+URLEncoder.encode(login_pass,"UTF-8");
              bufferedWriter.write(data);
              bufferedWriter.flush();
              bufferedWriter.close();
              outputStream.close();
              InputStream inputStream = httpURLConnection.getInputStream();
              BufferedReader bufferedReader = new BufferedReader (new InputStreamReader(inputStream,"iso-8859-1"));
              String response = "";
              String line = "";
              while ((line = bufferedReader.readLine())!=null)
              {
                  response+= line;
              }
              bufferedReader.close();
              inputStream.close();
              httpURLConnection.disconnect();
              return response;
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
      return null;
  }
  
  @Override
  protected void onProgressUpdate(Void... values) {
      super.onProgressUpdate(values);
  }
  
  @Override
  protected void onPostExecute(String result) {
      if(result.equals("Registration Has Been Successful."))
      {
          Toast.makeText(ctx, result, Toast.LENGTH_LONG).show();
      }
  else
      {
          alertDialog.setMessage(result);
          alertDialog.show();
      }
  
  }
  }
  </code></pre>