• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps android using web service with php

GinfoB

Lurker
Hi everyone
i would like anyone have an idea how to compare login in edittext android and login in php
i have this method to check login and password
  1. if(isset($_POST["action"])){
  2. $result["success"]=false;if($_POST["action"]=="login"){if($_POST["login"]=="toto"&& $_POST["password"]=="toto"){
  3. $result["success"]=true;
  4. $result["user"]=newUser();}else{
  5. $result["success"]=false;}}
and i have an LoginActivity like this retun jsonObject of user right now
  1. publicclassLoginActivityextendsActivity{

  2. JSONArray user;EditText username , password;Button btn;TextView txt1;String server;HttpResponse response;List<NameValuePair> nameValuePairs;

  3. @Overrideprotectedvoid onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);
  4. setContentView(R.layout.activity_login);
  5. username =(EditText)findViewById(R.id.username);
  6. password =(EditText)findViewById(R.id.password);
  7. txt1=(TextView)findViewById(R.id.tv);




  8. server ="http://localhost:8082/API/";AsyncHttpClient client =newAsyncHttpClient();RequestParams p =newRequestParams();
  9. p.put("login","admin");
  10. p.put("password","admin");
  11. p.put("action","login");
  12. client.post(server, p,newJsonHttpResponseHandler(){

  13. @Overridepublicvoid onSuccess(int statusCode,Header[] headers,JSONObject response){

  14. try{

  15. txt1.setText(response.getJSONObject("user").toString());


  16. /* JSONObject result = new JSONObject();
  17. result.get(response.getString("login"));

  18. txt1.setText(result.toString());*/

  19. }catch(JSONException e){

  20. e.printStackTrace();}



  21. }


  22. });}
first i want to know how to compare $_POST["login"] == "toto" and login (editText) in android for example in my android apps LoginActivity i see like this UserName : and Password : and button OK i would like when i click in button ok get the login (toto) in php and comprare with the android (login) and if true toto = toto i want to display to my simple message like "you are Loginin".
 
Back
Top Bottom