In PHP, what are some common methods for handling form submissions and redirecting to different pages based on user input?

When handling form submissions in PHP, one common method is to use conditional statements to check the user input and redirect to different pages based on that input. This can be achieved by using the header() function to redirect to a new page after processing the form data.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data
    $userInput = $_POST['input'];

    if ($userInput == 'option1') {
        header("Location: page1.php");
        exit();
    } elseif ($userInput == 'option2') {
        header("Location: page2.php");
        exit();
    } else {
        header("Location: error.php");
        exit();
    }
}
?>