In the provided PHP code snippet, what improvements could be made to enhance readability and maintainability?

The provided PHP code snippet lacks proper indentation and comments, making it difficult to understand and maintain. To enhance readability and maintainability, we can add comments to explain the purpose of each section of code and properly indent the code to show the hierarchy of control structures.

<?php

// Retrieve user input from form
$username = $_POST['username'];
$password = $_POST['password'];

// Validate user input
if (empty($username) || empty($password)) {
    echo "Username and password are required.";
    exit;
}

// Check if username and password are valid
if ($username === 'admin' && $password === 'password') {
    echo "Login successful!";
} else {
    echo "Invalid username or password.";
}

?>