Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Based on Today's Date, send to this page

1. ## Based on Today's Date, send to this page

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

• 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.
PHP Code:
``` //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");  ```

• ## Users who have thanked mlseim for this post:

NathanLedet (01-08-2008)

• Yeah I want to write my own script. I just needed a kick in the right direction, which you certainly provided! Thanks very much!!

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•