重定向到外部链接之前的中间页面

i'm novice in php and already searched the forum for this and found something similar although i don't understand it

i have 2 external links http://www.hello.com and http://www.bye.com

on click on each link, i want to load an intermediate page (eg: redirect.php) for 5 second with a

message: "You are leaving misite.com. goodbye."

and then, make the correct to the correct external link that applies in each case.

i need:

1.- content of redirect.php

  <a href="<?php $hello.com = $_GET['link']; ?>">Continue to external link</a>
  <a href="<?php $link = $_GET['link']; ?>">Continue to external link</a>

i'm sure it's wrong. also, i don't know how to put a 5 seconds spinner (gif) an then make the redirection (step3)

2.- link users click on it. is it ok? i have:

  <a href="http://redirect.php?link=hello.com" title="hello">hello</a>

not sure if it's correct the link the users hit, tries to call the link in the redirect page, but i'm unable

well, the thing i don't know how to make it work and i really aprecciate an example thanks

You should make your link to redirect.php, and add the "final destination" as a URL parameter, as you have already done. On redirect.php, use a meta tag in the head section that redirects (see here for an example).

EDIT: Code requested...

In your main php page, have your links as you already wrote:

<a href="http://redirect.php?link=hello.com">Hello</a>
<a href="http://redirect.php?link=goodbye.com">Goodbye</a>

In redirect.php, you need to add a meta tag in the <head>...</head> section of your HTML:

<html>
    <head>
        ...
        <meta http-equiv="refresh" content="5;url=<?php echo $_GET['link'];?>" />
        ...
    </head>
    <body>
        <h1>You are leaving my site!</h1>
        <img src="/images/spinner.gif" alt="spinner" />
    </body>
</html>

and that's it. The meta tag "content" attribute contains the number of seconds before redirecting, and the address to redirect to.

Hope this helps.