To show a countdown, you'll need js. To provide a 'sorry you're too early', an easy solution would be to set a session variable (or cookie).
first page
<?php
session_start();
if(isset($_SESSION['allowed_view'])){
$delay = $_SESSION['allowed_view'] - time(); //for redirects back to this page
$error_msg = "<p>You cannot proceed until the countdown is finished.</p>";
}else{
$delay = '30'; //countdown time in seconds for first time page entry
$error_msg = "";
$_SESSION['allowed_view'] = time() + $delay; //set time at which page can be redirected
}
//place your timer (either js for coundown display - place in head area OR php with refresh method, if countdown not impt - USING $delay as timer).
?>
second page
<?php
session_start();
$current = time();
if(!isset($_SESSION['allowed_view']) || $current < $_SESSION['allowed_view']){
//redirect back to sending page
}else{
unset($_SESSION['allowed_view']); //safely remove this variable - or do something more exotic.
}
?>
Top of head stuff, so don't know if it'll work without a fiddle. Haven't included a coundown script - that you can do yourself - loads of free scripts available.
Last edited by ardav; Mar 8th, 2010 at 12:58 pm.
Reputation Points: 1041
Solved Threads: 935
Sarcastic Poster
Offline 6,620 posts
since Oct 2006