Jump to content

Help Required For A Date Sensitive Referal Php Script


mervpayne

Recommended Posts

Hi,

 

I have a new project on the go that requires a 'redirect.php' page to contain some code which checks the date and sends the user to a new page dependent on the date.

 

All going well when I set up and tested yesterday, but ran into problems today. Here's a sample of the code:

 

<?php

$hour = date('G');

$minute = date('i');

$day = date('w');

$m = $hour * 60 + $minute; // Minutes since midnight.

if(strtotime("2012/12/6") <= time()) {

header("location: http://www.myurl.com/06122012.htm");

exit;

}

if(strtotime("2012/12/7") <= time()) {

header("location: http://www.myurl.com/07122012.htm");

exit;

}

if(strtotime("2012/12/9") <= time()) {

header("location: http://www.myurl.com/09122012.htm");

exit;

}

if(strtotime("2012/12/12") <= time()) {

header("location: http://www.smyurl.com12122012.htm");

exit;

}

?>

 

Like I say it worked yesterday (6/12 - it went to the 06122012.htm page) but today, when I was expecting it to go to the 7/12 content, it didn't, iit still went to the 6/12 content. I can see why, (I tested it by removing the 6/12 bit of the script and of course it went to the 7/12 content) but I can't work out how to include a new piece of script that tells it 'if the date has passed go on to the next date check'

 

I guess it's something simple, along the lines of checking what the actual current date is, but I can't figure it out, any help would be much appreciated!

 

Thanks

To have a static html document for every day in the calendar completely defeats the purpose of using a dynamic language like PHP. It would be much more efficient to just load content based on the date than to redirect to a page with a file name that matches the date.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.