title: How to register user info from android studio to 000webhost.com database(php)?
body: <p>I'm trying to insert user info to 000webhost database (phpMyAdmin) from android studio. My database is connected however I can't post anything in the database. Can somebody help me with that? </p>
  
  <pre><code>    registerbutton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              register();
  });
  }
  
  public void register() {
  
      FirstName = firstname.getText().toString();
      LastName = lastname.getText().toString();
      Email = email.getText().toString();
      Password = pass.getText().toString();
      Password2 = pass2.getText().toString();
      BackGround bg = new BackGround();
      bg.execute(FirstName, LastName, Email, Password, Password2);
  
  
  }
  
  class BackGround extends AsyncTask&lt;String, String, String&gt; {
  
      @Override
      protected String doInBackground(String... params) {
  
          String firstname = params[0];
          String lastname = params[1];
          String email = params[2];
          String pass = params[3];
          String pass2 = params[5];
          String data = "";
          int temp;
  
          try {
              URL url = new URL("https://lovethesnipers.000webhostapp.com/register.php");
              String urlParams = "firstname=" + firstname + "&amp;lastname=" + lastname +
                      "&amp;email=" + email + "&amp;pass=" + pass + "&amp;pass2=" + pass2;
  
              HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
              httpURLConnection.setDoOutput(true);
  
              OutputStream os = httpURLConnection.getOutputStream();
              os.write(urlParams.getBytes());
              os.flush();
              os.close();
  
              InputStream is = httpURLConnection.getInputStream();
              while ((temp = is.read()) != -1) {
                  data += (char) temp;
  
              }
              is.close();
              httpURLConnection.disconnect();
  
              return data;
  
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
              return "Exception: " + e.getMessage();
  
          }
          return null;
      }
  
      @Override
      protected void onPostExecute(String s) {
          if (s.equals("")) {
              s = "Register Successful.";
          }
          Toast.makeText(AppRegisterActivity.this, s, Toast.LENGTH_LONG).show();
      }
  }
  
  }
  </code></pre>
  
  <p>This is my register.php in server side </p>
  
  <pre><code>&lt;?php
  error_reporting(0);
  require "init.php";
  
  $firstname = $_POST["firstname"];
  $lastname = $_POST["lastname"];
  $email = $_POST["email"];
  $pass = $_POST["pass"];
  $pass2 = $_POST["pass2"];
  //$statement = mysqli_prepare($con, "INSERT INTO users_info (id,firstname,  
    lastname, email, pass, pass2) VALUES (null,?, ?, ?, ?,?)");
  
  $sql = "INSERT INTO users_info(id, firstname, lastname, email, pass, pass2)  VALUES (?, ?, ?,?,?)";
  
  mysqli_stmt_bind_param($sql, "siss", $firstname, $lastname, $email, $pass, $pass2);
  mysqli_stmt_execute($sql);
  
  if(!mysqli_query($conn, $sql)){
  echo '{"Unable to save the data to the database"}';
  
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>My database name is table name is user_info and the fields are id, firstname, lastname, email, pass, and pass2. It is connected but every time I hit the register button it doesn't pass the value to the database. Thank you for your help in advance. </p>