Page Redirect After Certain Time PHP

Page redirect after certain time PHP


header( "refresh:5;url=wherever.php" );

this is the php way to set header which will redirect you to wherever.php in 5 seconds


Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file. (source php.net)

PHP redirect after 5 seconds

Use header Refresh.
It is simple:

header("Refresh:5; url=register.php");

It should work, make sure no output is before this header.

Redirect with Timer in PHP?

You can cause your PHP script to sleep for 10 seconds,

sleep(10);

but this will appear to the end-user as a non-responsive server. The best option is to use either a meta refresh,

<meta http-equiv="refresh" content="10;url=http://google.com">

or javascript.

setTimeout(function(){
window.location = "http://google.com";
}, 10000);

Found in the comments from Daniel:

header('Refresh: 10; URL=http://yoursite.com/page.php');

would be ideal for this situation, as it requires no Javascript or HTML.

How to Redirect Page in PHP after a few seconds without meta http-equiv=REFRESH CONTENT=time

Try use "refresh" header:

header('Refresh: 3;url=page.php');

Also, you can look at this Question Refresh HTTP Header.

Redirect website after specified amount of time


<meta http-equiv="refresh" content="3;url=http://www.google.com/" />


Related Topics



Leave a reply



Submit