Search code examples
phphtmlhref

HTML link out page


I am trying to make it so that when someone clicks a link on my site, they will be redirected to an out.php page and then taken to the site the link was aimed at. I wanted to do this so I could display a goodbye message to the user.

I have been looking for a way to do this for a while now but I cannot find any solutions to my problem.

If anyone has any ideas on how I could do this, I would love to know.

Thanks


Solution

  • Something like this should do the trick:

    out.php

    <?php 
    
    $url = urldecode($_GET['target']);
    echo 'Thank you for visiting, you will be taken to ... in 5 seconds';
    echo "<script> setTimeout('window.location = \"$url\";', 5000);</script>";
    

    Normal script

    echo '<a target="_blank" href="out.php?target=' . urlencode($targetUrl) . '">Click</a>';