How can PHP and HTML code be properly separated and organized to improve code readability and maintainability in a login script?

To improve code readability and maintainability in a login script, PHP and HTML code can be properly separated by using a templating system like PHP's built-in `include` function or a more robust templating engine like Twig. This allows for the logic (PHP code) and presentation (HTML code) to be separated, making the code easier to read and maintain.

// login.php

<?php
// PHP logic for processing login form submission

include 'header.php'; // Include header HTML
?>

<!-- HTML login form -->
<form action="login.php" method="post">
    <input type="text" name="username" placeholder="Username">
    <input type="password" name="password" placeholder="Password">
    <button type="submit">Login</button>
</form>

<?php
include 'footer.php'; // Include footer HTML
?>