Is it possible to 'hash' to $ x-variable?

1

Hi, I would like to know if it is possible to do the following:

 $id_user = $_POST['id_user'];
 $nivel_auth = $_POST['nivel'];
 $hash_nivel = hash($nivel_auth);
 $con = "INSERT INTO usuario (nivel) VALUES ($hash_nivel) WHERE id_user=$id_user;

Is it good to use hash in $var ?

Would any "verification" error occur when checking the base de datos to bring the id_nivel stored?

As for security , does it improve or is it still equal to a $var stored as such?

    
asked by Juan 29.01.2018 в 19:37
source

1 answer

1

Fix this line you are missing "[":

 $nivel_auth = $_POST'nivel'];

Change it to:

$nivel_auth = $_POST['nivel'];
  

Is it good to use hash in $ var?

Yes because it gives an extra layer of security to your application

  

Would a "verification" error occur when checking the database to retrieve the stored level_id?

There would be no reason for me to give you an error in the verification because when you make the comparison it will always be against the same value. That is, hash the value of the bd against the hash of the value entered by the user, for example.

  

Regarding security, does it improve or does it remain the same as a $ varalmacenada as such?

It greatly improves security, adds one more level because if by chance a third party manages to capture the value on the path could not know what exactly because it does not "know" the original value entered so the data for the third would be "useless".

    
answered by 30.01.2018 / 00:56
source