HTML dated pages
Author
Discussion

philip_cooke

Original Poster:

5,845 posts

311 months

Saturday 25th February 2006
quotequote all
I'm writing a very basic set of 'home-pages' and want to know if there's any way I can write a page but not have it appear until a certain date, or even better, date and time. I want to be able to put the page on my server and leave it there, and then when the date/time is reached, the page to be made visible to the 'net.

Is this possible in a simple way? or do I need some complex system?

ErnestM

11,621 posts

297 months

Saturday 25th February 2006
quotequote all
Depends what you mean by "complex". Any decent content management system will do it for you and you don't even need to code HTML. Postnuke or Mambo are two...

ErnestM

philip_cooke

Original Poster:

5,845 posts

311 months

Sunday 26th February 2006
quotequote all
Thanks, but I'm not totally sure if that is what I'm after. I've had a very brief look at both of their home pages and I wouldn't know where to start. Let me explain my scenario. I'm writing a very simple website to publicise my forthcoming wedding, so that Family, Friedns etc can get extra details (Maps etc) online. Our Honeymoon is a surprise (only the travel agent and I know where) so I want to write a 'spoof' honeymoon page and then have the real honeymoon page appear after we've let for it.

My webpages are hosted on my ISP space, I don't want to (or can't) leave my PC running connected to the ISP, so I need to have a way of making the right page appear at the right time.

I don't want to leave it for a person, as I'd have to give them my username/password etc to be able to upload the pages. Plus I don't think any of my family are technically mided enough to have a clue!!

Any ideas?

GreenV8S

31,024 posts

314 months

Sunday 26th February 2006
quotequote all
How about writing a spoof page with a bit of script that redirects to the right page, but only if 'now' is after the specified date?

philip_cooke

Original Poster:

5,845 posts

311 months

Sunday 26th February 2006
quotequote all
Peter, I guess writing script falls into my category of 'complex'. I was hoping there would be a simple HTML 'function' that would let me do this.

Onyone out there any good at writing code, and if so, how do I use it? Peter, any help please?

UncleDave

7,155 posts

261 months

Sunday 26th February 2006
quotequote all
There are some scripts available, could be quie easy depending on when you want the pages to change (ie. once a day? once a week?)

Feel free to drop me a mail
Dave.

wildeep

362 posts

279 months

Sunday 26th February 2006
quotequote all
you could use a bit of javascript to detect the day of the month and redirect to the relevant page. Something like this might do.

[html]
[head]
[script language="JavaScript"]

[!--
var today = new Date();
var dayofmonth = today.getDate();
window.location = dayofmonth + ".html";
// --]

[/script]
[/head]
[body][/body]
[/html]

*you will need to change the square brackets

m12_nathan

5,138 posts

289 months

Sunday 26th February 2006
quotequote all
wildeep said:
you could use a bit of javascript to detect the day of the month and redirect to the relevant page. Something like this might do.

[html]
[head]
[script language="JavaScript"]

[!--
var today = new Date();
var dayofmonth = today.getDate();
window.location = dayofmonth + ".html";
// --]

[/script]
[/head]
[body][/body]
[/html]

*you will need to change the square brackets


Except that the javascript is client side so the url for the page you want to remain a secret would be viewable.

a simple server side asp response.redirect or the php version of the same based on the date would be perfect.

philip_cooke

Original Poster:

5,845 posts

311 months

Sunday 26th February 2006
quotequote all
Thanks for the code, but where (or how) do I put my requested date in. Do I put this code in the page that is visible before, or the page that is visible after. Also, where do I put the re-direct address? Sorry, but I'm not very hot on code or anything more advanced than "10 print hello, 20 goto 10"

wildeep said:
you could use a bit of javascript to detect the day of the month and redirect to the relevant page. Something like this might do.

[html]
[head]
[script language="JavaScript"]

[!--
var today = new Date();
var dayofmonth = today.getDate();
window.location = dayofmonth + ".html";
// --]

[/script]
[/head]
[body][/body]
[/html]

*you will need to change the square brackets

GreenV8S

31,024 posts

314 months

Monday 27th February 2006
quotequote all
If you're doing it client side then I would have a 'front' page that redirects to either the dummy or the main page. This way the source of your front page won't be visible to the casual viewer.

wildeep

362 posts

279 months

Monday 27th February 2006
quotequote all
Ok, if you dont want to do it client side then there is a another way. create a page called index.php or you can call it index.html if your server will parse HTML pages for php code and insert the following code in it, making sure to replace the first and last square brackets with angle brackets.

[?php
$day = date('j');
if($day <= 6) // insert before date here
header("Location: www.yourdomainname.co.uk/beforethe6th.html" ); // fake honeymoon page URL
else if($day > 6) //insert after date here
header("Location: www.yourdomainname.co.uk/afterthe6th.html" ); // real honeymoon page URL
?]

then just enter the date you want the page to change, in my example i have used the 6th, and the URLs of both the real and fake honeymoon pages. If your honeymoon is going to go over to another month then the page will change back but then we can add an extra few lines to detect the month as well.

>> Edited by wildeep on Monday 27th February 09:13

beanbag

7,346 posts

271 months

Monday 27th February 2006
quotequote all
Just out of curiosity....do you have PHP installed?

If so it's very very simple!

You actually write both pages to the same file but one bit shows on one date and then the other part after your specified date.

Example:


Beanbags PHP example said:

<?php
$current_date = date("dmY";

$show_page_date = "10052006"; // Enter here the date you want your page to show

if ($current_date < $show_page_date)
{
?>

<!-- Begin Spoof Website Page -->
<HTML>
<HEAD>
<TITLE>SPOOF WEBSITE</TITLE>
</HEAD>
<BODY>
Stuff in Spoof Website
</BODY>
</HTML>
<!-- End Spoof Website Page -->

<?php
}
else
{
?>

<!-- Begin Real Website Page -->
<HTML>
<HEAD>
<TITLE>REAL WEBSITE</TITLE>
</HEAD>
<BODY>
Stuff in Real Website
</BODY>
</HTML>
<!-- End Website Page -->

<?php>
}
?>

beanbag

7,346 posts

271 months

Monday 27th February 2006
quotequote all
wildeep said:
Ok, if you dont want to do it client side then there is a another way. create a page called index.php or you can call it index.html if your server will parse HTML pages for php code and insert the following code in it, making sure to replace the first and last square brackets with angle brackets.

[?php
$day = date('j');
if($day <= 6) // insert before date here
header("Location: www.yourdomainname.co.uk/beforethe6th.html" ); // fake honeymoon page URL
else if($day > 6) //insert after date here
header("Location: www.yourdomainname.co.uk/afterthe6th.html" ); // real honeymoon page URL
?]

then just enter the date you want the page to change, in my example i have used the 6th, and the URLs of both the real and fake honeymoon pages. If your honeymoon is going to go over to another month then the page will change back but then we can add an extra few lines to detect the month as well.

>> Edited by wildeep on Monday 27th February 09:13


Damn! Same thing really and you beat me!! grrr!

wildeep

362 posts

279 months

Monday 27th February 2006
quotequote all
beanbag said:
Damn! Same thing really and you beat me!! grrr!


your way looks a bit simpler to mine

philip_cooke

Original Poster:

5,845 posts

311 months

Monday 27th February 2006
quotequote all
Beanbag, I've just checked my ISP and it says I can use PHP, now I just have to play around and see if it can read PHP from within HTML or if I need to write a PHP file. I'll have a play tonight and see how I get on.

Very many thanks for all of your help. Guess I now need to write a test page and see how I get on.

Cheers guys!!

beanbag

7,346 posts

271 months

Monday 27th February 2006
quotequote all
philip_cooke said:
Beanbag, I've just checked my ISP and it says I can use PHP, now I just have to play around and see if it can read PHP from within HTML or if I need to write a PHP file. I'll have a play tonight and see how I get on.

Very many thanks for all of your help. Guess I now need to write a test page and see how I get on.

Cheers guys!!


No probs! If you need any help, email me and i'll have a look at your code.

philip_cooke

Original Poster:

5,845 posts

311 months

Monday 27th February 2006
quotequote all
Well, Having said that my ISP uses CGI, I now find that it's NOT one of the options I can use on my account. Is there any way I can use something else to do this date thing? Wildeep gave some javascript but I don't know how to apply it. If anyone can show me where to put the date etc, I'd be very grateful.

Cheers in advance,

philip_cooke

Original Poster:

5,845 posts

311 months

Monday 27th February 2006
quotequote all
wildeep said:

[html]
[head]
[script language="JavaScript"]

[!--
var today = new Date();
var dayofmonth = today.getDate();
if(dayofmonth > 27) (window.location = "realhoneymoon.htm";
// --]

[/script]
[/head]
[body]FAKE HONEYMOON PAGE DETAILS[/body]
[/html]

*you will need to change the square brackets


Well, I've now managed to get this to work (slightly modified) but it opens up the link into a new window. How can I keep it in the same window without another being opened? Also, I've tried to add the monthofyear into the script but can't get it to work. Can you show me how to add it in please?