php link cloak via base64 encryption -- need help

1.2k Views Asked by At

I used to have a script that basically base64 encoded the link and then the redirect PHP page would decode it and send you off to the page.

I don't know what I am doing wrong and PHP is not my best skill, just looking for some help.

Link on page:

<a href="http://www.XXXXXX.com/find.php?shop=<?php echo urlencode(base64_encode("long ass link goes here"));  ?>">Test</a> 

find.php:

< ?php

    $request_id = $_GET ['shop'];
    $site = base64_decode($request_id);

    header( 'Location: $site' ) ;

?>
2

There are 2 best solutions below

7
On BEST ANSWER

If you want to use $variables in strings, use double quotes:

header("Location: $site");

Or concatenate the strings:

header('Location: '.$site);

More info here

+++ But better store that value into $_SESSION, because users can change it and it will bring up errors.

3
On

If you copied and pasted that second code, try removing the space between < and ?. It should be <?php.