does anybody have a script that will let me display a 'you will be directed in 5 sec, as your login was unsuccesfull' kind of thing, i need some kind of delay / timer function ?
Printable View
does anybody have a script that will let me display a 'you will be directed in 5 sec, as your login was unsuccesfull' kind of thing, i need some kind of delay / timer function ?
Remember to include the http:// protocol and domain, as well as the page.PHP Code:header('Refresh: 5; URL=http://example.com/mynewlocation');
This is often used to get the user one step away from the POST request, so that they don't go back and accidentally submit things again. However, I dislike this method; partly because the delay is annoying (and often not long enough to read the text anyway), and partly because it doesn't really solve the problem: if you hit Back twice, you can still get to the expired POST request, which shouldn't be cached at all.
The superior solution is to silently redirect using a 303 code. This tells the browser that it must not cache the POST request. If the user then presses the Back button, they'll be taken back to the page where the form submission was made (in this case, the login screen).
For more information, see HTTP/1.1: Status Code Definitions.PHP Code:header('HTTP/1.1 303 See Other');
header('Location: http://example.com/mynewlocation');
Leaving out the status modification will cause PHP to send a 302 status code. The browser should honour the redirection with the same HTTP method as the original request, but the majority (if not all) use a GET request.
If you want to force a POST redirection, send a 307 status. This will often cause the browser to generate a warning though as it could potentially be used to send form data to another site.
I haven't tried 307 but 303 works fine and I use it with all of my forms.