Auto Page Refresh using PHP

0
Your rating: None

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");
?>

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Cumulus Tag Cloud

Kiran Says

SEO Architect,SEO Specialist reflect my values.

By enduring black hat methods the SEO industry is setting itself up for washout and sleepwalking into oblivion.

Jobs in India