I had to look into this because I had a form that I wanted to show a thank you message for a moment and then have it redirect back to the main page.
Now the first thought is to use:
The problem with this is that as I’m displaying a message beforehand. This becomes an invalid PHP function as it is not first thing being executed.
This is what I found works nicely:
It is set to wait 3 seconds before redirecting. That is how you can display a message on the page and then have it redirect to another page with a delay so that the visitor has a chance to read the message.
I hope you find this little bit of code useful.