내 Android 앱에 비밀번호 분실 페이지가 있습니다. 이메일을 입력하지 않으면 서버에서 올바른 응답을 반환하고 데이터베이스에있는 이메일을 입력하면 사용자에게 이메일을 보내고 서버에서 올바른 응답을 반환합니다. 그러나 이메일에 입력 한 내용이 데이터베이스에없는 경우 전화 할 때HTTPEntity null 값 제공
HttpEntity entity = response.getEntity();
엔티티는 null 값입니다. 2 가지 경우에는 효과가 있지만 3 가지에는 효과가없는 이유는 확실하지 않습니다.
누구나 그 이유를 알고 있습니까?
private void accessURL(String url) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
if (url.equalsIgnoreCase(Global.forgotPasswordURL)) {
InputStream is = null;
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("email", email.getText().toString()));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
if(entity != null){
is = entity.getContent();
String jsonResult = inputStreamToString(is).toString();
if (jsonResult.equalsIgnoreCase("Please enter your Email")) {
new AlertDialog.Builder(this).setTitle("Please Enter Your Email Address")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// continue with delete
}
}).show();
}else if(jsonResult.equalsIgnoreCase("Email Address Not Found")){
new AlertDialog.Builder(this).setTitle("The Email Address You Entered has not Been Found").setMessage("Make sure that you entered your email correctly.")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}else{
new AlertDialog.Builder(this).setTitle("Your Email Has Been Found!").setMessage("Check the email you provied for further instructions on resetting your password.")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}
}else{
Log.d("Null", "null");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
PHP 코드 :
if (isset($_POST["email"]) && !empty($_POST['email'])) {
$con=mysqli_connect("localhost","***********","******","*******");
$email = $_POST['email'];
$query = mysql_query("SELECT * FROM users WHERE email = '$email'");
$query2 = mysql_query("SELECT * FROM tempusers WHERE email = '$email'");
$ans = mysql_num_rows($query);
$ans2 = mysql_num_rows($query2);
$str = $ans . " " . $ans2;
if(mysql_num_rows($query) == 0 && mysql_num_rows($query2) == 0){
sendResponse(205, "Email Address Not Found");
return false;
}
$temp = false;
if(mysql_num_rows($query2) != 0){
$temp = true;
$query1 = mysql_query("SELECT * FROM tempusers WHERE email = '$email'");
$row = mysql_fetch_array($query1);
mailUser($email, $row['firstname'], $temp);
sendResponse(200, "Email Address Found".$str);
return true;
}else{
$query1 = mysql_query("SELECT * FROM users WHERE email = '$email'");
$row = mysql_fetch_array($query1);
mailUser($email, $row['firstname'], $temp);
sendResponse(200, "Email Address Found".$str);
return true;
}
}
sendResponse(400, 'Please enter your Email');
return false;
이 어떤 도움이 고정이 크게 감사하겠습니다, 감사
안드로이드 코드를 다음과 같이 내 코드입니다!
감사합니다. 다른 사람과 다른 상태 코드가있는 유일한 이유는 응용 프로그램의 iPhone 버전에서 세 가지 다른 경우를 구별하기 위해 세 번째 상태 코드가 필요했기 때문에 다른 코드를 선택했기 때문입니다. – shadowarcher