Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

encoding url not working

$
0
0

I'm trying to encode a url like this,

$code = '2';

header('Location: http://www.whatever.com/page.php?='.urlencode($code).'');
exit();

and then decoding it on the page.php page like this,

$url = $_SERVER['REQUEST_URI'];
$decodedurl = urldecode($url);

$code = $_GET[$decodedurl];

echo $code;

But when the header redirects to page.php, "2" doesn't get encoded, it just says "page.php?code=2"

 

How can I get this to work? Thanks for your time.


Viewing all articles
Browse latest Browse all 13200

Trending Articles