我收到了从 php 到 android 的响应,请参见下面的 .php
<?php
$username = $_POST[username];
$password = $_POST[password];
if($username == "himm")
{
if($password == "rangde"){
echo "success" ;
}
else{
echo "passwor is wrong.";
}
}
else
{
echo "fail";
}
?>
我在android的logcat窗口中取得了成功。但是在android中我做了如下比较,
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result = sb.toString();
Log.v("","Result : "+result);
Log.v("","this is Result: "+result.equalsIgnoreCase("success"));
if(result.equals("success")){
Log.v("","Login successfully......");
}
else{
Log.v("","Fail to login......");
}
但在 logcat 窗口中,我看到“登录失败”消息。Php 以“成功”的形式发送响应,但是哪种类型?这里 if(result.equals("success")) 的条件应该为真。请任何人给我想法或建议来实现这个目标............提前谢谢你