...

View Full Version : Based on Today's Date, send to this page



NathanLedet
01-08-2008, 02:21 PM
I'd like a very small script that would determine the date, and if the date falls between 2 dates, then the user would be forwarded to one page, and if it falls between another 2 dates, then they will be forwarded to another page.

I think this should be fairly simple, but i'm still learning PHP. Thanks :thumbsup:

mlseim
01-08-2008, 02:33 PM
Specific dates (including year), or any year, like Jan 1 to April 15th?

Here's today's date:

$year=date("Y");
$month=date("m");
$day=date("d");

$year would be 2008
$month would be 01
$day would be 08

See the manual:
http://us2.php.net/date

... and the if statement ...
You have a logic problem ... what if it doesn't fall between either dates?

This is sort of the idea ... you should write your own script and then
come back to the forum for help with problems. You wouldn't learn much
if we wrote the script for you.


//get today's date
$year=date("Y");
$month=date("m");
$day=date("d");
//do your calculations here ... all of the math
// ... math stuff
//$date1 is true if it falls between 1st 2 dates.
//$date2 is true if it falls between 2nd 2 dates.

//where it goes if it doesn't fall between either date.
$url = "http://www.mysite.com/nodates.html";

if($date1){
$url = "http://www.mysite.com/date1_page.html";
}
if($date2){
$url = "http://www.mysite.com/date2_page.html";
}
header ("location: $url");

NathanLedet
01-08-2008, 03:20 PM
Yeah I want to write my own script. I just needed a kick in the right direction, which you certainly provided! Thanks very much!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum