Skip to content Skip to sidebar Skip to footer

Php Response To Http Request From Android

I've searched alot to find a way to send HTTP Response to Android Application that sends HTTP Request with Username and Password My problem is I want to take the username and pass

Solution 1:

The values you want will be in the $row array. You can access them (depending on the column you want) like this $row[0], $row[1], etc.

It looks like the response currently is just the echo'd value 0 or 1

Why not just append them to that string separated by an uncommon character like the pipe or asterisk then split it back up?

Your echo then would be something like

echo 1."|".$row[0]."|".$row[1];

etc.

** Also, I should add the obigitory "hash your passwords and consider security"

Solution 2:

try this

try{
                     HttpClienthttpclient=newDefaultHttpClient();
                     HttpPosthttppost=newHttpPost(url);
                     httppost.setEntity(newUrlEncodedFormEntity(nameValuePairs));
                     HttpResponseresponse= httpclient.execute(httppost);
                     Stringthe_string_response= convertResponseToString(response);
                     Toast.makeText(getApplicationContext(), "Response " + the_string_response, Toast.LENGTH_LONG).show();
                 }catch(Exception e){
                       Toast.makeText(getApplicationContext(), "ERROR " + e.getMessage(), Toast.LENGTH_LONG).show();
                      System.out.println("Error in http connection "+e.toString());
                 }

Post a Comment for "Php Response To Http Request From Android"