我正在尝试通过连接到我的数据库并验证用户名和密码来制作登录表单,我正在使用 JSON 方法
public class LoginActivity extends Activity {
JSONParser jParser = new JSONParser();
private static String url_login = "http://192.168.1.81:80get_all_usernames.php";
JSONArray admin = null;
int i;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.adminlogin);
}
public void enter(View v)
{
TextView user= (TextView) findViewById (R.id.user);
TextView pass= (TextView) findViewById (R.id.pass);
CharSequence usr= user.getText();
CharSequence pwd=pass.getText();
Log.i("",""+usr);
Log.i("",""+pwd);
ArrayList<NameValuePair> param = new ArrayList<NameValuePair>();
JSONObject json = jParser.makeHttpRequest(url_login, "GET",param);
Log.i("","fjefejjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
try{
int success = json.getInt("success");
if(success == 1){
admin = json.getJSONArray("admin");
for(i=0;i<admin.length();i++){
final JSONObject c = admin.getJSONObject(i);
String real_user=c.getString("username");
String real_password= c.getString("password");
if(usr==real_user && pwd==real_password)
{
Log.i("success","login sucessfull-----------------------");
}
else{
Log.i("fail","Login failed ----------------------------------");
}
}}
}catch(Exception e){
}
}
}
它一直在该行返回错误: JSONObject json = jParser.makeHttpRequest(url_login, "GET",param); 有人可以帮我吗?
提前谢谢你,拉尔夫