How can PHP be used to redirect users to specific pages based on form submissions?

To redirect users to specific pages based on form submissions in PHP, you can use the header() function to send a raw HTTP header to the browser. You can check the form data submitted by the user and then use a conditional statement to determine which page to redirect the user to.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($_POST["form_field"] == "value1") {
        header("Location: page1.php");
        exit;
    } elseif ($_POST["form_field"] == "value2") {
        header("Location: page2.php");
        exit;
    } else {
        header("Location: default_page.php");
        exit;
    }
}
?>