Log in

View Full Version : A time out link



R.T.
11-18-2007, 12:51 AM
Hi,
I am looking for what would more than likely be simple code for some one that knows html. I have just never had the time to learn much. A good share of my work on our site has been to modify others or letting front page do the work.
What I am looking for is a page that would time out at a date and time and then jump to a second page. So when some one clicked the link after "time out" they would be sent to the second page only.
Any ideas?

R.T.

djr33
11-18-2007, 01:52 AM
Find the time with your language [see below], then redirect to the second page if it is after that time.

Javascript:
Not secure and could be bypassed, but doesn't require a server side language to be installed on the server. It would also work live, for a page already loaded.
Basically, if the current time is greater than the set time, switch the document.location to your next page.

PHP:
Same idea, but this is server side (or you could use ASP, etc., too). You need it installed on your server, though.
This would redirect instead of loading the page if it was after the time. Completely secure, too.
You'd still need javascript for a page that has already been loaded to redirect, though.

BLiZZaRD
11-18-2007, 04:05 AM
Well, the complications of this are that your time is different, server time, your local time, my local time, GMT/UTC etc. all different. SO if you have a page expire on Thursday of next week, some will have it expire 47 hours before/after others.

If this isn't a concern, then converting the date to expire into a day, month and year and giving a header Location can be done in PHP:



<?php
if (date("m") >= 11 && date("d") >= 17 && date("Y") >=2007) header('Location: http://www.example.com/newpage.html');
?>


or... something like that.. :p

R.T.
11-19-2007, 05:30 AM
Thanks Blizzard. That code should do the job. Correct, if our site was for World wide, time would be a problem. But it is really for a local membership, so we will all have the same time.

R.T.

BLiZZaRD
11-19-2007, 05:32 AM
Okay, but still be careful of Server time vs. your local time. You may have to adjust if your on one coast and your server is on another (like mine) :D