I intend to use GET for my form but would like to encrypt the values in the query string so that users are not able to change it. (not for security, but for data hiding purposes)
I came across a couple of websites which explained encryption, but it is not clear to me how to implement it once the user presses the submit button. Ex: http://myscriptlibrary.wordpress.com/2010/04/14/how-to-encrypt-query-string-in-php/
Is there an example which could show this?
Thanks.
From my understanding of the link that you provided. You want to encrypt the GET variables, or at least obfuscate them.
The best and easiest way that this could be done is using base64_decode/encode
For example to encode the string you would do something like:
$link = "http://www.example.com/?item=".urlencode(base64_encode("user-data"));
$link
would look something like http://www.example.com/?item=rklgEwkelnf%3D%3D
, but to translate the seemingly garbled (base64ed) text into something usable you would use:
foreach($_GET as $loc=>$item)
$_GET[$loc] = base64_decode(urldecode($item));
Then you can freely use the $_GET
variable as you normally would.
The accepted answer here doesn't provide any real protection. You can just take the encoded parameters and put them into an online base64_decode and it shows the values as if you have just passed them directly!
The other answer uses $hash as a pass through value but that value hasn't been defined only $hashed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With