Ajax can do it. Plain js can do it. OR php can do it via header refresh. The plain js window.location using time intervals is the usual method, but if js is not enabled, I don't think that the page will be redirected.
header( 'refresh: 30; url=http://www.example.com/index.php' );
...(rest of page)....
After 30 seconds, the page is redirected or refreshed (if sent to itself).
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
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.
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080