I want to display the echo for 5 seconds and redirect the page to login.html but when the page loads it takes 5 seconds instead of loading the page and waiting 5 sec then redirect.
<?php
session_start();
if (isset($_SESSION['name'])) {
echo $_SESSION['name'];
} else {
echo "Login To Order";
sleep(5);
echo "<script type=\"text/javascript\">
window.location.href = \"login.html\";
</script>";
}
?>
EDIT: ok this seems to delay it for 5 seconds but the code execution still continues further but I want it to stop =>echo for 5 seconds =>redirect to the other page.
echo "Login To Order";
echo "<script type=\"text/javascript\">
window.setTimeout(function() {
window.location.href=\"login.html\";
}, 5000);
</script>";
echo "this should not be displayed";
echo "this should not be displayed"; my point here is that I have others codes below that I don't want to be executed in the else case.