How can you redirect to a specific page after successfully submitting a form in PHP?

After successfully submitting a form in PHP, you can redirect the user to a specific page using the header() function. You need to call the header() function before any output is sent to the browser to avoid any errors. Simply set the Location header to the URL of the page you want to redirect to.

<?php
// Process form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Handle form data
    
    // Redirect to a specific page
    header("Location: http://www.example.com/thank-you.php");
    exit();
}
?>