What method can be used to dynamically redirect users to different web pages based on form input in PHP?

To dynamically redirect users to different web pages based on form input in PHP, you can use the header() function to send a raw HTTP header to the browser, which will redirect the user to the specified URL. You can use a conditional statement to check the form input and determine which URL to redirect the user to.

<?php
if(isset($_POST['submit'])){
    $input = $_POST['input']; // Assuming 'input' is the name of the form field
    if($input == 'page1'){
        header("Location: page1.php");
        exit();
    } elseif($input == 'page2'){
        header("Location: page2.php");
        exit();
    } else {
        header("Location: default.php");
        exit();
    }
}
?>