1
的回聲
請我真的需要你的幫助,從昨天阻止:「(閱讀POST請求爲Android
// MY X VAR
int x ;
// IM執行check_referrer()函數到我按一下按鈕聽者
signupJoinBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
username = signupUsername.getText().toString();
referrercode = signupReferrer.getText().toString();
x =check_referrer(username,referrercode);
// Check_推薦人應該讀 「1」 或 「0」 從我的PHP文件(我測試我的PHP文件,他的工作)
public int check_referrer(String referral, String referrer ) {
String awr = Config.Base_Url + "get/checkref.php";
final String v1 = "1"; // OK
final String v0 = "0"; // The referrer is not existing
StringRequest stringRequest = new StringRequest(Request.Method.POST,awr,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
if (response.equals(v1)) {
x= 1;
}
else if (response.equals(v0)) {
x= 0;
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
// user is the variable my php file will receive
params.put("user",username);
// user is the variable my php file will receive
params.put("ref", referrercode);
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
return x;
}