How can PHP be used to display different HTML pages based on the validation of a form?

To display different HTML pages based on the validation of a form in PHP, you can use conditional statements to check the form input and redirect the user to the appropriate page. After validating the form input, you can use header() function to redirect the user to the desired page.

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

    if (/* validation condition */) {
        header("Location: success.html");
        exit();
    } else {
        header("Location: error.html");
        exit();
    }
}
?>