Page Redirection after a Specified Time Interval in PHP
In PHP, you can effortlessly redirect a user to a different page after a certain period of time. This functionality is particularly useful for scenarios such as email verification or automatic sign-outs.
Solution:
To implement this time-based redirection, you can utilize the header() function with the refresh parameter. The syntax is as follows:
header( "refresh:time_in_seconds;url=destination.php" );
Example:
Suppose you want to redirect the user to success.php after 5 seconds. You would use the following code:
header( "refresh:5;url=success.php" );
Important Note:
It's crucial to remember that the header() function must be called before any output is sent to the browser. This means avoiding HTML tags, blank lines, or PHP output before invoking header(). Failure to do so will result in an error.
The above is the detailed content of How Can I Redirect Users in PHP After a Specific Time Interval?. For more information, please follow other related articles on the PHP Chinese website!