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
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
- if(isset($_POST["action"])){
- $result["success"]=false;if($_POST["action"]=="login"){if($_POST["login"]=="toto"&& $_POST["password"]=="toto"){
- $result["success"]=true;
- $result["user"]=newUser();}else{
- $result["success"]=false;}}
- publicclassLoginActivityextendsActivity{
- JSONArray user;EditText username , password;Button btn;TextView txt1;String server;HttpResponse response;List<NameValuePair> nameValuePairs;
- @Overrideprotectedvoid onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_login);
- username =(EditText)findViewById(R.id.username);
- password =(EditText)findViewById(R.id.password);
- txt1=(TextView)findViewById(R.id.tv);
- server ="http://localhost:8082/API/";AsyncHttpClient client =newAsyncHttpClient();RequestParams p =newRequestParams();
- p.put("login","admin");
- p.put("password","admin");
- p.put("action","login");
- client.post(server, p,newJsonHttpResponseHandler(){
- @Overridepublicvoid onSuccess(int statusCode,Header[] headers,JSONObject response){
- try{
- txt1.setText(response.getJSONObject("user").toString());
- /* JSONObject result = new JSONObject();
- result.get(response.getString("login"));
- txt1.setText(result.toString());*/
- }catch(JSONException e){
- e.printStackTrace();}
- }
- });}
