2
我想提出一個簡單的寄存器應用,在那裏用戶註冊和數據存儲在My MYDATABASE像USENAME,姓名,年齡存儲密碼時應我的數據不在數據庫中
我在phpMyAdmin,我已經創建的數據庫表上載Register.php文件到我的服務器我檢查Register.php文件他們是沒有錯誤,它的工作原理很好(我使用郵政應用程序作爲應用程序發送註冊詳細信息到服務器它實際上工作我的數據庫存儲的郵遞員發送的值應用程序,但當我使用Android應用程序和註冊數據不存儲在我的數據庫)
他們應該是我的代碼中的一些錯誤,但錯誤沒有顯示我需要整天解決問題仍未找到。
我指的是本教程https://www.youtube.com/watch?v=T7Z4GVFaT4A&list=PLe60o7ed8E-TztoF2K3y4VdDgT6APZ0ka&index=4
我使用凌空我gradle這個文件
這裏註冊活動的網絡圖書館,讓用戶輸入用戶名,姓名,年齡,密碼是存儲和發送回另一個活動發送服務器
它與XML文件鏈接whre用戶可以登錄
public class RegisterActivity extends AppCompatActivity {
EditText username , name , pass , age;
Button r_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
username = (EditText)findViewById(R.id.username_et);
name = (EditText)findViewById(R.id.name_et);
pass = (EditText)findViewById(R.id.pass_et);
age = (EditText)findViewById(R.id.age_et);
r_button = (Button)findViewById(R.id.register_button);
r_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String usname = username.getText().toString();
String nam = name.getText().toString();
String password = pass.getText().toString();
int ages = Integer.parseInt(age.getText().toString());
Response.Listener<String> responselistner = 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);
startActivity(intent);
//after successfull sign up it redirect to login page
}
else
{
AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
builder.setMessage("Registration failed")
.setNegativeButton("retry",null)
.create()
.show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
RegisterRequest registerRequest = new RegisterRequest(nam, usname,ages,password , responselistner);
RequestQueue requestQueue = Volley.newRequestQueue(RegisterActivity.this);
requestQueue.add(registerRequest);
}
});
}
}
這裏是我的類RegisterRequest
public class RegisterRequest extends StringRequest {
private static final String REGISTER_REQUEST_URL ="http://fgeeges.esy.es/Register.php";
private Map<String, String> params;
public RegisterRequest(String name , String username , int age , 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("age" ,age+"");
params.put("password",password);
}
}
我應該在哪裏添加這個,爲什麼我添加可以給我reasone –
你可以添加一個關於這是什麼的小解釋 – Shogunivar
它是註冊用戶可以輸入名稱用戶名年齡密碼,這個細節是存儲在數據庫我也提供視頻的鏈接 –