What is the recommended method in PHP to redirect to a new page after form submission?

After submitting a form in PHP, the recommended method to redirect to a new page is to use the header() function with the Location header set to the desired URL. This method sends a raw HTTP header to the browser, instructing it to redirect to the specified page. It is important to note that the header() function must be called before any actual output is sent to the browser to avoid errors.

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