echo "<meta http-equiv=\"refresh\" content=\"4;URL=inbox.php\">";
change 0 to 4 can do this
Frage
I want to hold an echo function for 4 seconds and after that refresh the php page but instead sleep() function holds all of echo functions and then refresh the page. this is my code how can I fix this ?
if($sql_new!='')
{
$_SESSION["count"]="";
echo "<div class='cleaner h30'></div>";
echo "<b'>Inbox informations Submitted successfully!</b>";
sleep(4);
echo "<meta http-equiv=\"refresh\" content=\"0;URL=inbox.php\">";
}
Lösung
echo "<meta http-equiv=\"refresh\" content=\"4;URL=inbox.php\">";
change 0 to 4 can do this
Andere Tipps
Remove the sleep code from your PHP - it is just delaying the output of the HMTL to the browser. It is the meta tag in the code that needs to be updated to trigger to the browser to refresh the page 4 seconds after the page has loaded.
echo "<meta http-equiv=\"refresh\" content=\"4;URL=inbox.php\">";
Just another solution: there IS a way to archive what you were triying to do. YOu just have to make sure that the content you echo'ed before the sleep
is already sent to the browser before you sleep. YOu can do so by:
flush()
Not saying you should do this, just you can.
Here is something I worked up to redirect. Seems to work fine and thought I would share.
DelayTime(15);
echo "<script>window.top.location.reload();</script>";
The DelayTime Function:
function DelayTime($secs){
$now = time();
while($now < ($now + $sec)){
$now = time();
if($now >= ($now + $sec)){ break; }
}
return true;
}