简体   繁体   中英

How to encode (base64) and decode(base64) more than one variable which is passing via url in php

I want to pass more than one variable via url. I do not want to show those values to the user.Therefore while passing the variable via url I encode the by base64 and in another file I decode it and I will use. I am able to do this for one variable.But, I want to implement the same for more than one variable. I am not getting how to do this.

Can anyone assist me?

My code is,

encode.php

<?php
    $link = "decrypt.php?item=".urlencode(base64_encode('testing'))."";
    echo '<a href='.$link.'>click here</a>';
?>

decode.php

<?php
    foreach($_GET as $loc=>$item)
       $_GET[$loc] = base64_decode(urldecode($item));
       echo $_GET[$loc];
?>

But, I should pass more than one like

<a href="test.php?name="Suma"&place="India"">click</a>

How do I do this?

I got answer:)

I have like this,

My code is,

encode.php

<?php
    $link = "decrypt.php? 
   item=".urlencode(base64_encode('testing'))."&rate=".urlencode(base64_encode('10'))."";
echo '<a href='.$link.'>click here</a>';
?>

decode.php

<?php
    echo base64_decode(urldecode($_GET['item']));
    echo base64_decode(urldecode($_GET['rate']));
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM