How can the header() function be used to perform a redirect in PHP after a specific action is completed?
To perform a redirect in PHP after a specific action is completed, you can use the header() function to send a raw HTTP header to the browser, indicating a redirect to a new location. This is commonly used after form submissions or other actions that require redirection to a different page.
// Perform specific action
// Redirect to a new location after action is completed
header("Location: new_page.php");
exit();
Keywords
Related Questions
- Are there any security considerations to keep in mind when implementing automatic URL redirection in PHP?
- How can PHP developers efficiently process XML data with encoding errors while maintaining data integrity?
- How can you efficiently handle pagination of results in PHP when retrieving data from a database?