How can PHP be used to redirect to a new page after submitting a form?

After submitting a form in PHP, you can use the header() function to redirect the user to a new page. This function sends a raw HTTP header to the browser, which tells it to navigate to the specified URL. Make sure to call the header() function before any output is sent to the browser to avoid any errors.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process your form data here
    
    // Redirect to a new page
    header("Location: new_page.php");
    exit();
}
?>