Android login authentication to remote MySQL database
<p>Here's my java code:</p>

<pre><code>btnLogin.setOnClickListener(new View.OnClickListener() {

 @Override
     $public void onClick(View v) {

    ArrayList&lt;NameValuePair&gt; postParameters = new ArrayList&lt;NameValuePair&gt;();  
    postParameters.add(new BasicNameValuePair("username", txtUsername.getText().toString()));  
    postParameters.add(new BasicNameValuePair("password", txtPassword.getText().toString())); 




//String valid = "1";  
String response = null;  
try {  
response = CustomHttpClient.executeHttpPost("http://www.sampleweb.com/imba.php", postParameters);  
String res=response.toString();  
// res = res.trim();  
res= res.replaceAll("\\s+","");  
//error.setText(res);  
if(res.equals("1")){
txtError.setText("Correct Username or Password"); 
//Intent i = new Intent(CDroidMonitoringActivity.this, MenuClass.class);
//startActivity(i);
}
else {
txtError.setText("Sorry!! Incorrect Username or Password");  
} 
} catch (Exception e) { 
txtUsername.setText(e.toString());  

}

  }
            });
        }
</code></pre>

<p>I thinks there's an error in my res.equals because it keeps saying "Invalid Username or password" even though I've entered the correct username or password. But when I change the res.equals to res.contains it keeps saying "correct username or password" even though i've entered the correct username and password. I really need your help. to all mastered in android development. Hope you could help me on this. And also, when i change the txtError.setText(res) just to check if it returns 1 and 0 it does not. </p>
