I need to update with the sig, code but I do not get it Android, php, mysql

1

This is my PHP code to update.

 <?php 
 if($_SERVER['REQUEST_METHOD']=='POST'){
 //Getting values 
 $Code= $_POST['Code'];
 $user = $_POST['user'];
 $Pass= $_POST['Pass'];
 $TipoUsuario = $_POST['TipoUsuario'];

 //importing database connection script 
<br>
 require_once('dbConnect.php');

 //Creating sql query 
<br>
 $sql = "UPDATE Usuario SET user = '$user',Pass = '$Pass', TipoUsuario = '$TipoUsuario' WHERE Code = '$Code';";

 //Updating database table <br>

 if(mysqli_query($con,$sql)){
<br>
 echo 'Usuario actualizado correctamente';
<br>
 }else{
<br>
 echo 'No se  pudo actualizar el usuario';
 }

 //closing connection
<br> 
 mysqli_close($con);
 }
?>
</pre>

This is my Android code (Java)

 private void updateUsuario(){
    final  String Code=et1.getText().toString();
    final String User = et2.getText().toString().trim();
    final String Pass = et3.getText().toString().trim();
    final String TipoUsuario =tipUser .getSelectedItem().toString().trim();

    class UpdateUsuario extends AsyncTask<Void,Void,String>{
        ProgressDialog loading;
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            loading = ProgressDialog.show(buscarUpdateUser.this,"Updating...","Wait...",false,false);
        }

        @Override
        protected void onPostExecute(String s) {
            super.onPostExecute(s);
            loading.dismiss();
            Toast.makeText(buscarUpdateUser.this,s,Toast.LENGTH_LONG).show();
        }

        @Override
        protected String doInBackground(Void... params) {
            HashMap<String,String> hashMap = new HashMap<>();
            hashMap.put(Config.KEY_USER_CODE,Code);
            hashMap.put(Config.KEY_USER_USUARIO,User);
            hashMap.put(Config.KEY_USER_PASS,Pass);
            hashMap.put(Config.KEY_USER_TIPOUSER,TipoUsuario);

            RequestHandler rh = new RequestHandler();

            String s = rh.sendPostRequest(Config.URL_UPDATE_USER,hashMap);

            return s;
        }
    }

    UpdateUsuario ue = new UpdateUsuario();
    ue.execute();
}
    
asked by Sofia 20.02.2017 в 01:04
source

1 answer

0

You just have to make sure that the values of the constants defined in class Config are the same that your .php file will receive when making the post:

KEY_USER_CODE = "Code";
KEY_USER_USUARIO = "user";
KEY_USER_PASS = "Pass";
KEY_USER_TIPOUSER = "TipoUsuario";
    
answered by 20.02.2017 в 02:00