I am a PHP newbie, and although I have done some programming (not a lot) in the distant past (Pascal, Fortran, Assembly, dabbled in C slightly,) please forgive me if this is a classic "newbie's" dumb question.
I just implemented a WordPress-based online registration form for an upcoming event. Registration will be closing on a specific date, and I am trying to create a PHP routine with the following logic:
If registration is open, the Registration Form should be displayed;
If registration is closed, a Registration is Closed page/message should be displayed.
I have the date comparison code written and it works like a charm provided all I do is echo "hard coded" text to the screen.
Both the Registration Form and the Registration is Closed pages are WordPress pages within my site and can be accessesd via Permalinks/URLs.
Although I could hardcode the content of each of these two pages into my PHP routine, I would prefer to point to the two pages to facilitate future content updates/changes/additions/etc.
Additionally, I would like to implement this routine as a ShortCode which would be placed on its own WordPress page. The page containing the shortcode would be accessed via a Menu Tab on my page - when the tab is clicked (i.e., someone wants to register,) the PHP routine would ascertain the status of Registration (i.e., open or closed,) and then display the appropriate page.
Here is my code as it stands now (with text hardcoded within the echo construct rather than my pages' urls...):
<?php
/* This compares today's date with the date registration closes.
If registration is open, the registration page will be displayed.
If registration is closed, the registration is closed page is displayed.
*/
$reg_close_date = "2013-04-08";
$todays_date = date("Y-m-d");
$today = strtotime($todays_date);
$registration_closed_date = strtotime($reg_close_date);
if ($registration_closed_date >= $today){
echo 'display registration form';
}
else {
echo 'display registration is closed form';
}
?>
As I mentioned earlier, I am a PHP newbie, and I GREATLT appreciate any help anyone can offer... For all I know, what I would like to do is not possible, although I suspect my use of echo constructs may be the incorrect choice for what I want to achieve.
Thanks in advance!
Nancy