For refreshing a PHP page after a pre-defined amount of time for what ever reason like automatically refreshing the home page (or subpages) for updated news, just add the following script at the very beginning of your page. Any other header sent before this header function will make it cause an error.
<?php
header("Refresh: 60;");
?>
NOTE: The above code will make the current page automatically reloaded after 1 minutes, here the time is expressed in seconds.
You can also redirect to another page of your site or an external site after pre-determined time.
The following code will send the visitor to the blog (assuming you have the blog running under the folder "blog") after 10 seconds.
<?php
header("Refresh: 10; url=/blog/");
?>
This will send the visitor to www.php.net after 5 seconds.
<?php
header("Refresh: 5; url=http://www.php.net");
?>
- Kiran's blog
- 815 reads













Post new comment