Wordpress magazine themes - Play Piano by Ear - Gavin Newsom - Myspace Code - Wordpress magazine themes

PDA

View Full Version : Showing a loading image before site opens


fadetoblack22
Nov 25th 2008, 3:19 am
Hello, I have some external links on my site. I want a "site loading" page to display for a few seconds as the external link loads up.

Does anyone know how this is done?

This is my code to direct to external links - the page is called links.php:



<?php
$path = array(
'google' => 'http://www.google.com',
'yahoo'=> 'http://www.yahoo.com');
if (array_key_exists($_GET['id'], $path)) header('Location: ' . $path[$_GET['id']]);
?>



I link to them using:

www.mysite.com/links.php?id=google (or yahoo)

drew22299
Nov 25th 2008, 4:34 am
So basically a blank page is displayed while it's exectuing the PHP code. You could put html above the PHP tag at the top of the page and have a message or an image? For example,

<h3>Please wait, page is loading</h3>

<img src=""/>

PHP code here

or you could change the PHP code to echo the html

<?php

echo "Your message here";

$path = array(
'google' => 'http://www.google.com',
'yahoo'=> 'http://www.yahoo.com');
if (array_key_exists($_GET['id'], $path)) header('Location: ' . $path[$_GET['id']]);
?>

fadetoblack22
Nov 25th 2008, 5:51 am
So basically a blank page is displayed while it's exectuing the PHP code. You could put html above the PHP tag at the top of the page and have a message or an image? For example,

<h3>Please wait, page is loading</h3>

<img src=""/>

PHP code here

or you could change the PHP code to echo the html

<?php

echo "Your message here";

$path = array(
'google' => 'http://www.google.com',
'yahoo'=> 'http://www.yahoo.com');
if (array_key_exists($_GET['id'], $path)) header('Location: ' . $path[$_GET['id']]);
?>

I tried both ways but it shows an error:

Warning: Cannot modify header information - headers already sent by...on line 12. It looks like it is talking about the header in the "header('Location: ' . $path..."

I found a site that does what I want (the links on the 2nd half of the page):

http://www.freebetinfo.com/Football/Aalborg_v_Celtic-Champions_League-0809

e.g. this link: http://www.freebetinfo.com/link.php?p=boylesports

It uses a common file www.freebetinfo.com/link.php with a loading gif, but also uses a separate image for each link which is somehow placed on that page as well.

fadetoblack22
Nov 25th 2008, 6:13 am
Ok, I can see what the other site is doing now. Its using a javascript time delay on the link.

However I don't understand how it is combining this with the php link redirect. It has the php link id in the link which is sending it to a page and then using javascript with a link in it as well.

I can understand that a separate page with the javascript time delay is set up for each link, but I can't understand why its set up with a php link from the html page if the javascript links are on the same server anyway.

Can anyone help me out?

thanks.