How can the PHP script be modified to accurately display an error message when incorrect user information is entered?

When incorrect user information is entered, the PHP script can be modified to display an error message by adding an if statement to check if the user input matches the expected values. If the input is incorrect, an error message can be displayed using the echo function.

<?php
$username = "admin";
$password = "password";

$user_input_username = $_POST['username'];
$user_input_password = $_POST['password'];

if ($user_input_username != $username || $user_input_password != $password) {
    echo "Incorrect username or password. Please try again.";
} else {
    // Proceed with the rest of the script
}
?>