Android: http login not having desired effect -


i couldn't seem log in page work, kept telling me username/password incorrect when know not. started debugging , popping in log.v's , found interesting. line says "//<--- line!"

class logmein extends asynctask<string, void, string> {     httpclient client = new defaulthttpclient();     httppost post = new httppost("http://www.fakesite.com/login.php");      protected string doinbackground(string... urls) {          try {             username = un.gettext().tostring();             password = pw.gettext().tostring();             list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(                     2);             namevaluepairs                     .add(new basicnamevaluepair("username", username));             namevaluepairs                     .add(new basicnamevaluepair("password", password));             post.setentity(new urlencodedformentity(namevaluepairs));              httpresponse response = client.execute(post);             string res = inputstream(response.getentity().getcontent())                     .tostring();             log.v("response", res); // <--- line!              // if username , password valid, launch main activity             if (res.tostring() == "1") {                 intent login = new intent(getapplicationcontext(), main.class);                 startactivity(login);                                }              // send user message saying login failed             else {                 runonuithread(new runnable() {                     public void run() {                                                  pw.settext("");                         fail.settext(r.string.fail);                     }                 });             }         } catch (exception e) {             e.printstacktrace();         }          return null;     }      protected void onpostexecute(string file_url) {      } }  private stringbuilder inputstream(inputstream input) {     string line = "";     stringbuilder total = new stringbuilder();     bufferedreader read = new bufferedreader(new inputstreamreader(input));      try {         while ((line = read.readline()) != null) {             total.append(line);         }     } catch (exception e) {         e.printstacktrace();     }      return total; } 

now expecting response "true" or "1". based on know username/password correct , launch main activity , life goes on. got

05-18 15:41:27.620: v/response(27641):  <!--<script>window.location.href="";</script>-->       <!-- <meta http-equiv="refresh" content="0;url=">                -->  

furthermore if trim off /login.php @ end of url "http://www.whatever.com" wall of similar html longer.

needless i'm doing wrong, , login fails regardless of whether username/password correct. did go wrong? can't seem figure out.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -