1

I'm trying to send data to my database, when my register button is clicked without filling any field on the registration form it displays the "field empty" message but when I fill it and click the register button nothing happens. This is the code that is supposed to send the data

btn_signup.setOnClickListener(this);
    Button btn_signup = (Button) view.findViewById(R.id.btn_signup);
    btn_signup.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            registerUser();
        }
    });
}

@Override
public void onClick(View v) {

    switch (v.getId()) {
        case R.id.tv_login:
            break;

    }

}


private void registerUser() {

    String name = et_name.getText().toString();
    String email = et_email.getText().toString();
    String password = et_password.getText().toString();

    if (!name.isEmpty() && !email.isEmpty() && !password.isEmpty()) {


    } else {

        Snackbar.make(getView(), "Fields are empty !", Snackbar.LENGTH_LONG).show();
    }
}
        StringRequest strReq = new StringRequest(Method.POST,
                AppConfig.URL_REGISTER, new Response.Listener<String>() {

            @Override
            public void onResponse(String response) {
                Log.d(TAG, "Register Response: " + response.toString());
                hideDialog();

I defined my URL_REGISTER in my AppConfig.java like this

public class AppConfig {

public static String URL_LOGIN = "http://192.168.43.142/android_login_api/login.php";


public static String URL_REGISTER = "http://192.168.43.142/android_login_api/register.php";
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
Eric
  • 101
  • 1
  • 10

1 Answers1

1

Your Block is empty!!

if (!name.isEmpty() && !email.isEmpty() && !password.isEmpty()) {
  // you have to do something here to get some output
  } 
Bhuvanesh BS
  • 13,474
  • 12
  • 40
  • 66