Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.