How can the issue of passwords appearing in the address bar be prevented in PHP forms?

Issue: Passwords appearing in the address bar can be prevented by using the POST method in PHP forms instead of the GET method. This ensures that sensitive information, such as passwords, is not displayed in the URL.

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