Forum Moderators: coopster

Message Too Old, No Replies

help required on - redirect on time - script

         

SierraLeoneRadio

9:40 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



guys,

I'm desperately looking for someone who can help script the following :-

we need a script that will redirect a website visitor according to a specific time of day according to our server clock.

i.e. if it's after 7am, the visitor will get redirected to page A, however if it's before 7am, then visitor will get redirected to page B.

It's important that the time aspect of the script is measured against a central time or clock (i.e. server clock) as opposed to the user's computer clock.

It sounds VERY complicated. Can anybody help?

jatar_k

10:11 pm on Mar 3, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld

It sounds VERY complicated

au contraire my friend, it is actually very simple.

<?
$hourofday = date(Gi);
if ($hourofday <= 700) $url = "/pageA.html";
else $url = "/pageB.html";

header("Location: $url");
?>

coopster

10:30 pm on Mar 3, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Nice. I like that.

I think you'll want single quotation marks around the Gi though, otherwise PHP is going to throw a notice error:

$hourofday = date('Gi');

jatar_k

10:33 pm on Mar 3, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



good call coopster, forgot about that. ;)

SierraLeoneRadio

6:23 am on Mar 4, 2004 (gmt 0)

10+ Year Member



thanks guys for all your help.

I'm a bit green on scripting and have tried what you suggested, but get this error -

Cannot modify header information - headers already sent by (output started at d:\inetpub\sites\www.**********.net\web\time.php:18)

jatar_k

6:26 am on Mar 4, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



do you have a blank line before your <?

SierraLeoneRadio

7:52 am on Mar 4, 2004 (gmt 0)

10+ Year Member



yes,

is there anyway you can help?

cheers

Netizen

10:45 am on Mar 4, 2004 (gmt 0)

10+ Year Member



Remove the blank line :-)