there is login for my website.
3 pages which are used while logging into website are :-
1) login_form.html ( this html page has form in which users can fill data when they click submit it sends to login_validate.php)
2) login_validate.php ( this php page validates the input texts and if he is an authentic user it redirects them to home.php)
3) home.php
I want to make an android login page,when correct login username and password are entered instead of showing home.php it should show some other thing.
I am able to make a POST http request to login_validate.php ,and i am getting home.php as reply,
my problem is how can i know that login is successful as i am not getting any reply as success or failure.i am getting login_form.html when authentication is wrong and home.php when username and password are right....
in my android app how can i know whether he entered right username and password or not correct credentials from the data i got from the server now???
In login_validate.php return only 'Ok' or 'Bad' status. And then redirect manualy to any page you need.
Use Http Response to take a response from the php script you are posting your data to. It can echo a 0 or 1 depending on whether the authentication is successful. Now read the response in your app and redirect.
HttpClient client = new DefaultHttpClient();
String getURL = "http://www.example.in";
HttpGet get = new HttpGet(getURL);
HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null)
{
//do something with the response
Log.i("GET RESPONSE",EntityUtils.toString(resEntityGet));
}