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();