redirect landing page problem

hi .php gurus :), forum looks great and thought it would be of some quick help. i just need a quick solution to this… i’ve more than a couple of pages that i’ve designed as themes for my site.

index.php is the by default page but to replace this like on christmas if i’ve christmas.php and for new year i’ve newyear.php, i just want to be able to do something from the backend where I can just go and choose one of these three files and set as default and the users start landing to christmas.php or newyear.php.

just that is it, instead of changing files name from the ftp time and time again, i just want to be able to do control them like from a backend page or a page, where I can just call these three files and choose anyone of them and somehow set that as default page.

can anyone please help with some easy solution :slight_smile:

quick easy solution is place this in your index.php file:
// get the day
$day = date(‘j’);
// get the month
$month = date(‘F’);

// check against a set date
if($day == 25 && $month == ‘December’) // is it xmas?
include ‘index_xmas.php’;
elseif($day == 1 && $month == ‘January’) // is it new year?
include ‘index_newYear.php’;
else // just use the default.
include ‘index_default.php’;

then have your three files[sub] index_xmas.php[/sub][sup] index_newYear.php[/sup] [sub]index_default.php[/sub] in the same directory and depending on the date the included file will change.

If you wish, you could add more dates by simply extending the elseif part of the script.

hope this helps

having read through your post again, may i suggest you only use one index page and change the look/style by using CSS stylesheets and changing them depending upon the date rather than the index page.

In my opinion this would be a far better - and usually easier - than what you are aiming to do, although the script i posted above will do what you asked.


reading my script posted above i noticed a typo (an important one too! :-[)

the error has now been fixed :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service