Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryWeb Content Preparation

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Special Day Message on Your Web Page

Setting up a web page to publish custom content on a specific day is relatively easy using the technique presented here.

It requires a PHP web page. And two other things:

  1. Something to publish on the special day.

  2. The PHP code to set it up.

The content to publish is up to you. The PHP code is in this article.

The content to publish on the special day can be anything a web page can publish, such as prose, poems, images, videos, tables, forms – any combination of those.

There's example content in the instructions.

Implementation Instructions

Implementation uses 3 lines of PHP code and the special content. Here is a representation:

Line of PHP code.
Line of PHP code.
Your special contant (may be multi-line).
Line of PHP code.

The first and last lines of the PHP code are always the same. Here is the first line:

<?php list($Month,$Day,$Year)=explode(" ",date("n j Y")); ?>

The second line of PHP code is where you specify the day the special content is to be published. One or more of these need to specified: The month, the day, and/or the year.

For an example, let's assume the special message is to publish on Christmas Day, December 25 (the 12th month of the calendar). This is the code for the second line of PHP:

<?php if( $Month==12 and $Day==25 ): ?>

The above publishes the code on December 25th – of any year.

If only the month were specified in the second line of PHP code, then the special message would be published during the entire 12th month.

Here is an example of only the month being specified.

<?php if( $Month==12 ): ?>

The above publishes the special content every day during December – of any year.

The below publishes special content only on December 25, 2013.

<?php if( $Month==12 and $Day==25 and $Year==2013 ): ?>

For the special content, let's assume a Christmas greeting with red text and border and having a green background.

<div style="color:red; border:3px solid red; background-color:green; padding:10px; text-align:center; font-size:16px; font-weight:bold; letter-spacing:3px;">
Merry Christmas!
</div>

As mentioned earlier, the last line of PHP code is always the same:

<?php endif; ?>

Here is the example code putting the above all together.

<?php list($Month,$Day,$Year)=explode(" ",date("n j Y")); ?>
<?php if( $Month==12 and $Day==25 ): ?>
   <div style="color:red; border:3px solid red; background-color:green; padding:10px; text-align:center; font-size:16px; font-weight:bold; letter-spacing:3px;">
   Merry Christmas!
   </div>
<?php endif; ?>

Only the second line of the PHP code (in blue, above) ever needs to be customized; and that's to specify the month, day, and/or year to publish the special content.

The special content itself can be changed any time, of course.

For testing, change the second line of PHP code to match the current day. After testing, change it back for the day the special content is to be published.

The special day message is implemented with 3 lines of PHP code, plus your special message.

Special note for WebSite's Secret members: The Content Change by Holiday download found in the members area can be used to set up unlimited number of holidays a year or more in advance.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC