Alex Rivera | Logout

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

Asked 2012-06-22T10:32:14.307
17

It seems that it is not advisable to use

<meta http-equiv=REFRESH CONTENT=3;url=url>

for redirects but instead use

header('Location: url')

However, I would like to show the user some message and allow them some time to read it before redirecting. Is there a way to do it without meta?

Edit
Report

1 Answer

4

Header tags are sent on page load, to the browser, so that it can quickly redirect the user to the desired page without bothering to render it or even load it into the history. As such, you can't call a redirect once the page has already loaded, as the headers have already been dealt with.

You can instead perform this with:

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

Which basically sets the <meta> tag in the headers of the page itself, meaning you don't need to write the tag out.

answered 2012-06-22T10:38:19.897

Your Answer