I used the accepted solution in this question to encrypt the id, for example in /index.php?id=3. The problem is that I cannot send the encrypted value as a url like /index.php?id=dsf13f3343f23/23=. Because sometimes there are strange characters in the URL, for example, pay attention to the = symbol
Use PHP's
urlencode()function to encode the value before putting it in the URL.This function converts "strange" characters, such as
=, into a format that is safe to put in the URL. You can use it like this:Header('Location: /index.php?id=' . urlencode($id))Strange charactersin the value passed in the URL should be escaped usingurlencode()
.For example, the following code snippet:
echo urlencode('dsf13f3343f23/23=');will give: As a URL parameter, this is valid.If you want to build a query string with multiple parameters, check out the
For example: will give: This function will automatically handle escaping and parameter splicing;-)http_build_query()
function.