How can the header() function be used in PHP to redirect to a specific URL after form submission?

To redirect to a specific URL after form submission in PHP, you can use the header() function with the Location parameter set to the desired URL. This function sends a raw HTTP header to the browser, which will redirect the user to the specified URL.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data here

    // Redirect to a specific URL after form submission
    header("Location: http://www.example.com/thankyou.php");
    exit();
}
?>