Reputation: 43
How do I redirect page with PHP after 5 seconds to file register.php? No Javascript or other code, just plain PHP.
Is it possible? How do I do it? I've seen Location: header.
Upvotes: 3
Views: 31972
Reputation: 2256
You have a few options:
Refresh Header
header("Refresh:5; url=register.php");
Sleep then Location Header
sleep(5);
header("Location: register.php");
The first option is best, the sleep
in the 2nd is blocking and could be used to DDos your service.
Upvotes: 4
Reputation: 483
// sleep php process
sleep(5);
// redirect
header("location: register.php");
Upvotes: 1
Reputation: 503
Use header Refresh. It is simple:
header("Refresh:5; url=register.php");
It should work, make sure no output is before this header.
Upvotes: 10