您好我的应用程序中单击登录按钮会检查数据库中是否存在用户名和密码。
现在,我的问题是在点击此登录按钮后,用户找到了PHP的响应。
之后,在显示用户找到的数据变量中检查条件if(data.equalsIgnoreCase("User Found"))
。然后它转到其他条件。不检查if中的条件。
有人可以帮助我吗?
类文件
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String username = usname.getText().toString();
String password = pword.getText().toString();
if (username.equals("") || password.equals("")) {
if (username.equals("")) {
Toast.makeText(Login.this, "ENTER USERNAME",
Toast.LENGTH_LONG).show();
}
if (password.equals("")) {
Toast.makeText(Login.this, "ENTER PASSWORD",
Toast.LENGTH_LONG).show();
}
} else if (!CheckUsername(username) && !CheckPassword(password)){
Toast.makeText(Login.this, "ENTER VALID USERNAME & PASSWORD",
Toast.LENGTH_LONG).show();
}
else{
final String queryString = "username=" + username + "&password="
+ password;
final String data = DatabaseUtility.executeQueryPhp("login",queryString);
System.out.println("data :: "+data);
tv.setText("Response from PHP : " + data);
if(data.equalsIgnoreCase("User Found"))
{
Toast.makeText(getApplicationContext(),"Login Success", Toast.LENGTH_SHORT).show();
Intent i = new Intent(getApplicationContext(), Home.class);
startActivity(i);
}
else
{
Toast.makeText(getApplicationContext(),"User not found, check query", Toast.LENGTH_SHORT).show();
}
}
}
});