call HTTP POST android -


hello code in android app verify login. works fine want call http post method in php file can call more 1 method. how can that.

void login(){     try{                      httpclient=new defaulthttpclient();         httppost= new httppost("http://www.c-    iris.com/v2/app/webservice.php");          namevaluepairs = new arraylist<namevaluepair>(2);         // use same variable name posting i.e android side variable name , php side variable name should similar,          namevaluepairs.add(new basicnamevaluepair("username",et.gettext().tostring().trim()));  // $edittext_value = $_post['edittext_value'];         namevaluepairs.add(new basicnamevaluepair("password",pass.gettext().tostring().trim()));          httppost.setentity(new urlencodedformentity(namevaluepairs));         //execute http post request         response=httpclient.execute(httppost);         // edited james coderzheaven.. here....         responsehandler<string> responsehandler = new basicresponsehandler();         final string response = httpclient.execute(httppost, responsehandler);         system.out.println("response : " + response);          runonuithread(new runnable() {             public void run() {                 tv.settext("response php : " + response);                 dialog.dismiss();             }         });           if(response.equalsignorecase("user found")){             runonuithread(new runnable() {                 public void run() {                     toast.maketext(androidphpconnectiondemo.this,"login success", toast.length_short).show();                                }             });             //startactivity(new intent(androidphpconnectiondemo.this, userpage.class));              intent intent = new intent(this, userpage.class);             startactivity(intent);          }else{             showalert();                         }      }catch(exception e){         dialog.dismiss();         system.out.println("exception : " + e.getmessage());     } } 

this php file:

 <?php include ('../inc_php/databaseconnectie.php');  $username = $_post['username']; $password = $_post['password'];  $accountsquery = "select * database email = '".$username."' , wachtwoord =     '".md5($password)."'"; if ($accountsresult = $mysqli->query($accountsquery))  {    if ($accountsresult->num_rows >= 1)      {     echo "user found";  } else {     echo "no such user found"; } } ?> 

for example:

enter code here  if($_server['http_method'] === 'login') { //than execute code above....... } 

but how can call method android?

just comment below line

 //execute http post request   response=httpclient.execute(httppost); 

in log in method send data twice different objects remove above line in method.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -