 |
| Web Host Manager Anything to do with web host manager software |
|
|
|
|
Registered User
Status: Offline
Posts: 8
Join Date: Feb 2003
Rep Power: 0
|
Server-side script to load a page based on date? -
08-21-2008, 11:00 PM
Does Page Zone offer a PHP or CGI or some other type of server-side script that a customer can use to load a specific page depending on the date (day and month of the year) when someone accesses his site?
I run a website for a small hiking group and would like to find a script that would load a member's birthday page in lieu of our regular home page on dates that coincide with our members' birthdates. More specifically, if today is Al's birthday, then if any member of our group were to access our site today they would see, instead of our regular home page, a page created especially to honor Al on his birthday.
Is such a feature offered by PageZone or, if not, can someone direct me to such a script or help me to create it?
|
|
|
|
|
|
|
|
Registered User
Status: Offline
Posts: 9
Join Date: Aug 2008
Location: DC - B'more - Philly
Rep Power: 0
|
08-22-2008, 11:12 AM
Here's what I would try.
In Fantastico, you can install the " Web Calender" and I do know you can embed the calender in a website/page. The thing I am not sure of is whether you can force the calender to display the current day, if you can, then you've found your answer... it won't be easy but I think it can be done this way.
Good luck!
"We are all in the gutter, but some of us are looking at the stars." Oscar Wilde
|
|
|
|
|
|
|
|
Registered User
Status: Offline
Posts: 8
Join Date: Feb 2003
Rep Power: 0
|
08-22-2008, 10:40 PM
Thanks for your input, theunartist, but I’ve looked at Fantastico and I don’t see how I can adapt it to my purpose. I think I need a PHP script that would direct the server to serve up a specific page depending on the date. Most PHP scripts I have seen simply add content to a page based on various criteria. What I need is a script that would load an entire page depending on what day it is. I envision that it would work something like this:
if date = 9/21 then Al’s page
if date = 10/03 then Bill’s page
if date = 11/13 then Jim’s page
if date = else then home page
This script would be invisible to a member’s browser, but when a member accessed our website on the 21st of September, say, the server would load Al’s page and the member’s browser would display this page instead of our usual home page. I believe that this can be accomplished with a server-side script but I am at a loss as to how to write it and implement it.
|
|
|
|
|
|
|
|
of Page-Zone
Status: Offline
Posts: 1,130
Join Date: Jun 2002
Location: Wauseon, Ohio
|
08-22-2008, 11:03 PM
It's possible - but I've never seen or heard of a script that specifcally does that.
This would be a good start - Redirect with PHP Based on the Day of the Week but not exactly what you want. Someone with some php coding skills could probably modify it though.
|
|
|
|
|
|
|
|
Registered User
Status: Offline
Posts: 8
Join Date: Feb 2003
Rep Power: 0
|
08-23-2008, 01:17 PM
Thanks for the link, Jim. I think I may be able to hammer out something that will deliver what I need based on the guidelines offered at that site - and a bit of reading and research. I'll start working on it.
Thanks again for your input, and thank you for Page-Zone as well.
Bob Wilson
|
|
|
|
|
|
|
|
of Page-Zone
Status: Offline
Posts: 1,130
Join Date: Jun 2002
Location: Wauseon, Ohio
|
08-23-2008, 04:19 PM
This works:
Code:
<?php
$day = date("z") ;
switch($day){
case "234": header( 'Location: http://php.about.com' ) ; break;
case "235": header( 'Location: http://www.google.com' ) ; break;
case "236": header( 'Location: http://www.yahoo.com' ) ; break;
}
?>
Placed before any other code on the page. Today is day 235.
http://www.page-zone.com/sitemap2.php
edited to fix oversight. Now you just have to figure out which day of the year the bithdays are.
|
|
|
|
|
|
|
|
of Page-Zone
Status: Offline
Posts: 1,130
Join Date: Jun 2002
Location: Wauseon, Ohio
|
08-23-2008, 06:26 PM
And this works if you want to just input dates instead of the numerical day of the year:
Code:
<?php
$day = date("m d") ;
switch($day){
case "08 23": header( 'Location: http://php.about.com' ) ; break;
case "08 24": header( 'Location: http://www.google.com' ) ; break;
case "08 25": header( 'Location: http://www.yahoo.com' ) ; break;
}
?>
According to php manual you need to use the full URL for the redirect location
e.g. http://www.yoursite.tld/bob.html, not just /bob.html
|
|
|
|
|
|
|
|
Registered User
Status: Offline
Posts: 8
Join Date: Feb 2003
Rep Power: 0
|
08-23-2008, 06:48 PM
Thanks, Jim.
I added your php script to the very top of our home page html code and then renamed the page homeNR.php. I uploaded it to the server to test it and I got the error message below when I accessed with my browser:
Parse error: syntax error, unexpected T_VARIABLE in /home/mcpharts/public_html/members/homeNR.php on line 1
This did not happen when I tested your original code which looked at the days of the year instead of the month and day.
Any ideas?
Thanks again for your time.
Bob Wilson
|
|
|
|
|
|
|
|
of Page-Zone
Status: Offline
Posts: 1,130
Join Date: Jun 2002
Location: Wauseon, Ohio
|
08-23-2008, 08:30 PM
It looks like the code for that page is all on 1 line.
|
|
|
|
|
|
|
|
Registered User
Status: Offline
Posts: 8
Join Date: Feb 2003
Rep Power: 0
|
08-23-2008, 10:16 PM
I copied and pasted the script directly from your example posted today at 2:26PM. The only changes I made were to change "08 24" and "08 25" to "08 25" and "08 26" respectively (to see what would happen tomorrow, 08-24), and I changed the : header ( 'Location ... ') URLs to correspond to 3 of our birthday pages.
In my HTML editor (I use 1st Page 2006) the PHP script occupies the first 9 lines. The code for the entire page, start to finish, including the HTML code following the PHP script runs to a total of 183 lines.
|
|
|
|
|
|
|
|
of Page-Zone
Status: Offline
Posts: 1,130
Join Date: Jun 2002
Location: Wauseon, Ohio
|
08-23-2008, 11:00 PM
Something must be wrong in the upload or editor, because all newline characters are stripped. That's probably happening site wide, but doesn't matter in straight html (I don't think) I edited that file through SSH and added the line breaks back in.
Also this is (was) missing - Location: from the front of the redirect URL in your code.
But something in your editor, or the upload is mangling the code. It ws all on one line before I edited it, and a very long line  . Now just the html code is on one line.
Is there some compression feature in Firstpage that is enabled?
|
|
|
|
|
|
|
|
Registered User
Status: Offline
Posts: 8
Join Date: Feb 2003
Rep Power: 0
|
08-24-2008, 01:21 AM
Jim,
I don't think there is any compression feature enabled in my editor. I think the Parse error had something to do with how my FTP client handled the upload because I uploaded and overwrote the file on the server using cPanel's File Manager and now the "Parse error: syntax error" message is gone and it loads a page. But the page it loads is our home page, not the birthday page it should be loading today. Is it possible that 'Location: ' is still missing from the PHP syntax on the server? I have no way of knowing because when I right click the page and click "View Source" I see only the HTML code, parsed correctly, but not the PHP script.
I uploaded a file containing your original script that you posted here at 02:26PM today, positioned over some simple HTML code containing a text message and then accessed it with my browser and it worked like a charm, displaying the About.com page listed as the 'Location: ' for "08 23" and hiding the text message.
I compared the two scripts and can see no difference in syntax. The only difference I can think of is that the one I adapted, with the birthday page URLs as Locations, is positioned over a more complex page of HTML code.
Here is my adaptation of your script; maybe you can see something I missed:
<?php
$day = date("m d") ;
switch($day){
case "08 23": header( 'http://mcpharts.org/members/marty.htm' ) ; break;
case "08 25": header( 'http://mcpharts.org/members/brucenew.htm' ) ; break;
case "08 26": header( 'http://mcpharts.org/members/alan.html' ) ; break;
}
?>
This is positioned over the HTML code representing our home page.
Thank you for taking the time to work with me on this, Jim. I know you have other things you could be doing and I want you to know that I truly appreciate your help.
Bob Wilson
|
|
|
|
|
|
|
|
of Page-Zone
Status: Offline
Posts: 1,130
Join Date: Jun 2002
Location: Wauseon, Ohio
|
08-24-2008, 01:33 AM
Quote:
Originally Posted by BobW
Jim,
I don't think there is any compression feature enabled in my editor. I think the Parse error had something to do with how my FTP client handled the upload because I uploaded and overwrote the file on the server using cPanel's File Manager and now the "Parse error: syntax error" message is gone and it loads a page. But the page it loads is our home page, not the birthday page it should be loading today. Is it possible that 'Location: ' is still missing from the PHP syntax on the server? I have no way of knowing because when I right click the page and click "View Source" I see only the HTML code, parsed correctly, but not the PHP script.
I uploaded a file containing your original script that you posted here at 02:26PM today, positioned over some simple HTML code containing a text message and then accessed it with my browser and it worked like a charm, displaying the About.com page listed as the 'Location: ' for "08 23" and hiding the text message.
I compared the two scripts and can see no difference in syntax. The only difference I can think of is that the one I adapted, with the birthday page URLs as Locations, is positioned over a more complex page of HTML code.
Here is my adaptation of your script; maybe you can see something I missed:
<?php
$day = date("m d") ;
switch($day){
case "08 23": header( 'http://mcpharts.org/members/marty.htm' ) ; break;
case "08 25": header( 'http://mcpharts.org/members/brucenew.htm' ) ; break;
case "08 26": header( 'http://mcpharts.org/members/alan.html' ) ; break;
}
?>
This is positioned over the HTML code representing our home page.
Thank you for taking the time to work with me on this, Jim. I know you have other things you could be doing and I want you to know that I truly appreciate your help.
Bob Wilson
|
Yes, it's missing, compare the two, the code you posted and the code I posted
Code:
case "08 23": header( 'Location: 'http://mcpharts.org/members/marty.htm' ) ; break;
case "08 23": header( 'http://mcpharts.org/members/marty.htm' ) ; break;
No Location: in your code
|
|
|
|
|
|
|
|
Registered User
Status: Offline
Posts: 8
Join Date: Feb 2003
Rep Power: 0
|
08-24-2008, 02:30 AM
GOT IT! (finally). I think I've been on this too long today - I can't even see the obvious!
It looks like it's working now. But I think my FTP client is corrupting the files it uploads. Can you recommend a reliable FTP program?
Jim, I want to thank you for your help with this and for your patience today.
Bob Wilson
|
|
|
|
|