title: How to connect to a 000webhost database?
body: <p>I design a sign up screen in android studio and I connect it to the 000webhost database through php. I made database in 000webhost and also upload the php file on it. But the problem is when i pressed Register button in my app it crashes. Please tell me how to resolve this issue.</p>
  
  <pre><code>public class Registration extends AppCompatActivity {
  
      final String REG_API = "https://urkk.000webhostapp.com/AndroidAPI/registerUser.php";
      EditText editUsername, editEmail, editPassword, editContact;
      RadioButton rmale, rfemale;
      Button btnReg;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_registration);
  
          editUsername = findViewById(R.id.editUsername_ID);
          editEmail = findViewById(R.id.editUserEmail_ID);
          editPassword = findViewById(R.id.editUserPassword);
          editContact = findViewById(R.id.editUserContact);
          rmale = findViewById(R.id.radiobtnMale);
          rfemale = findViewById(R.id.radiobtnFemale);
          btnReg = findViewById(R.id.btnRegister_ID);
  
          btnReg.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  String name = editUsername.getText().toString();
                  String email = editEmail.getText().toString();
                  String password = editPassword.getText().toString();
                  String contact = editContact.getText().toString();
                  String gender = null;
                  if (rmale.isChecked())
                      gender = "Male";
                  if (rfemale.isChecked())
                      gender = "Female";
  
                  register(name, email, password, contact, gender);
              }
          });
      }
  
      public void register(final String strname, final String stremail, final String strpassword, final String strcontact, final String strgender) {
  
          StringRequest stringRequest = new StringRequest(Request.Method.POST, REG_API, new Response.Listener&lt;String&gt;() {
              @Override
              public void onResponse(String response) {
  
                  if (response.trim().equals("User Registered")) {
  
                      Toast.makeText(getApplicationContext(), "User Registered", Toast.LENGTH_SHORT).show();
                  } else {
                      Toast.makeText(getApplicationContext(), response, Toast.LENGTH_SHORT).show();
                  }
              }
          }, new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
  
                  Toast.makeText(getApplicationContext(), error.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
              }
          }) {
              @Override
              protected Map&lt;String, String&gt; getParams() throws AuthFailureError {
  
                  Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                  map.put("userName", strname);
                  map.put("userEmail", stremail);
                  map.put("userPassword", strpassword);
                  map.put("userContact", strcontact);
                  map.put("userGender", strgender);
  
                  return map;
              }
          };
          RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
          requestQueue.add(stringRequest);
      }
  }
  </code></pre>
  
  <p>Php code:</p>
  
  <pre><code>&lt;?php
  
      if($_SERVER['REQUEST_METHOD']=='POST'){
  
          $conn = mysqli_connect('localhost','id12762759_batman','imbatman','id12762759_users_db');
  
          $Name = $_POST['userName'];
          $Email = $_POST['userEmail'];
          $Password = $_POST['userPassword'];
          $Contact = $_POST['userContact'];
          $Gender = $_POST['userGender'];
  
          $q = "insert into tbl_users values ('','$Name','$Email','$Password','$Contact','$Gender')";
  
          $check = mysqli_query($conn,$q);
  
          if($check){
              echo 'User Registered';
  
          }
          else{
              echo 'Registration Failed';
          }
      }
      else{
          echo 'No Response';
      }
  
  ?&gt;
  </code></pre>