php - header location delay -


i have following php code want add delay too:

<?php     echo "message has been sent.";     header("location: page2.php", true, 303);     exit; ?> 

the above code happens fast can't see message:

i have tried:

<?php     sleep(5);     echo "message has been sent.";     header("location: page2.php", true, 303);     exit; ?> 

this doesn't display message either, sleep 5 seconds, waste of time.

how display message 5 second before redirecting?

you cannot http location redirect, redirect happen browser gets header. instead, use refresh redirect in header:

header( "refresh:5; url=http://www.example.com/page2.php", true, 303); 

this should work on modern browsers, not standardized, equivalent functionality use meta refresh redirect (meaning you'd have output full html too):

<meta http-equiv="refresh" content="5;url=http://www.example.com/page2.php">  

from the wikipedia page:

used in redirection, or when new resource has been created. refresh redirects after x seconds. proprietary, non-standard header extension introduced netscape , supported web browsers.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -