Are there any best practices for optimizing the display of messages in PHP forms to ensure a smooth user experience?

When displaying messages in PHP forms, it is important to ensure that the messages are clear, concise, and easily visible to the user. One best practice is to use different colors or icons to distinguish between different types of messages, such as success, error, or warning messages. Additionally, consider using animations or transitions to make the messages more noticeable and engaging for the user.

<?php
// Example of displaying a success message in a PHP form
if(isset($_SESSION['success_message'])){
    echo '<div class="success-message">' . $_SESSION['success_message'] . '</div>';
    unset($_SESSION['success_message']);
}
?>