0
我在Android Studio很新,我必須做一個項目,其中一個要求是註冊應該包含一個電子郵件地址,我的問題是,是否有可能把提供商的限制?就像只有以@ utem.edu.mx結尾的電子郵件才能註冊,那麼他們可以登錄?它應該在應用程序和數據庫的PHP連接上嗎?或者在Android Studio Activity中?電子郵件提供商限制 - Android Studio應用程序
THIS IS MY REGISTER活動
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
final EditText etEmail = (EditText) findViewById(R.id.etEmail);
final EditText etName = (EditText) findViewById(R.id.etName);
final EditText etUsername = (EditText) findViewById(R.id.etUsername);
final EditText etPassword = (EditText) findViewById(R.id.etPassword);
final Button btnRegister = (Button) findViewById(R.id.btnRegister);
btnRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String name = etName.getText().toString();
final String username = etUsername.getText().toString();
final String password = etPassword.getText().toString();
final String email = etEmail.getText().toString();
Response.Listener<String> responseListener = new Response.Listener<String>(){
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if (success){
Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);
RegisterActivity.this.startActivity(intent);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
builder.setMessage("Register Failed")
.setNegativeButton("Retry",null)
.create()
.show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
RegisterRequest registerRequest = new RegisterRequest(name, username, email, password,responseListener);
RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
queue.add(registerRequest);
}
});
THIS IS MY REGISTER請求活動
private static final String REGISTER_REQUEST_URL = "http://ubisutem.site88.net/Register.php";
private Map<String, String> params;
public RegisterRequest(String name, String username, String email, String password, Response.Listener<String> listener){
super(Method.POST,REGISTER_REQUEST_URL,listener, null);
params = new HashMap<>();
params.put("name", name);
params.put("username", username);
params.put("password", password);
params.put("email", email + "");
}
@Override
public Map<String, String> getParams(){
return params;
}
}
感謝:d
但是有沒有辦法讓只有一些像hotmail.com這樣的結尾電子郵件可以註冊?所以如果一個yahoo.com想要註冊他不應該能夠 – betterlaylow
是的 - 檢查電子郵件時,PHP應用程序得到它,檢查字符串結束,並確保其中一個你可以。 –