Is it advisable to display different error messages for incorrect usernames and passwords in a PHP login system?

It is advisable to display different error messages for incorrect usernames and passwords in a PHP login system to provide more specific feedback to the user. This can help them identify whether they mistyped their username or password, improving the user experience.

// Check if the username and password are correct
if ($username === $correctUsername && $password === $correctPassword) {
    // Login successful
} elseif ($username !== $correctUsername) {
    // Display error message for incorrect username
    echo "Incorrect username. Please try again.";
} elseif ($password !== $correctPassword) {
    // Display error message for incorrect password
    echo "Incorrect password. Please try again.";
}