Why is it recommended to use the POST method instead of the GET method for login forms in PHP?

Using the POST method for login forms in PHP is recommended over the GET method because POST requests do not expose sensitive information, such as passwords, in the URL. This helps to keep user credentials secure and prevents them from being easily visible in browser history or server logs.

<form action="login.php" method="post">
    <label for="username">Username:</label>
    <input type="text" id="username" name="username">
    <label for="password">Password:</label>
    <input type="password" id="password" name="password">
    <button type="submit">Login</button>
</form>