When a user enters wrong data, I want the page to show a message for 10 seconds, and then redirect to Google. When I use this code, the page redirects to Google without showing this message properly.
if($m==12 && $d==31)
{
echo "you entered wrong data";
sleep(10) ;
header("Location: http://google.com");
die();
}
How can I fix it?
You can’t respond to an HTTP request with a resource and a message that the resource that was requested can be found at a different URL.
If you want to redirect after a time period then you need to use a document level solution (such as
<meta>
or JavaScript).For instance:
That saidâ¦
People read at different speeds and people don’t always pay continual attention to a given browser window (start something loading and then switching to another tab is not uncommon).
I tend to work to the rule of thumb that if a message is worth displaying to the user, then it is worth displaying until they actively dismiss it.