2013-09-27 114 views
3

我有一個愚蠢的問題,我只是不知道。當我刷新我的登錄頁面時,密碼和用戶名會出現在輸入字段中。這裏是我的代碼:輸入字段中顯示密碼和用戶名?

<?php include_once "includes/scripts.php"; ?> 
<?php 
session_start(); 
include_once ("includes/connect.php"); 
if (isset($_SESSION['logged_in'])) { 
    header('location: admin_cms.php'); 
}else{ 
    if (isset($_POST['username'], $_POST['password'])){ 
     $username = $_POST['username']; 
     $password = md5($_POST['password']); 
     if (empty($username) or empty($password)){ 
      $error = '<p>NOTE: Fields are blank</p>'; 
     }else{ 
      $query = $pdo->prepare("SELECT * FROM users WHERE user_name = ? AND user_password =?"); 
      $query->bindValue(1, $username); 
      $query->bindValue(2, $password); 
      $query->execute(); 
      $num = $query->rowCount(); 
      if ($num == 1){ 
       $_SESSION['logged_in'] = true; 
       header('location: admin_cms.php'); 
       exit(); 
      }else{ 
       $error = "<p>NOTE: The username or password is incorrect</p>"; 
      } 
     } 
    } 
    ?> 
    <div id="login_container"> 
     <br><img src="images/camelhorst_logo_full.png" style="margin-top:38px;"> 
     <h1>LOGIN<img src="images/three_column_grid_line.png" alt="line"></h1> 
     <form acton = "admin.php" method="post" autocompleate="off"> 
      <label>Username:</label> 
      <input type="text" name="username" placeholder="Your Username" required> 
      <label>Password:</label> 
      <input type="password" name="password" placeholder="Your Password" required> 
      <input type="submit" value="Login" name="submit_login"> 
     </form> 
     <?php if (isset($error)) 
     {echo $error;}?> 
     <p id="copyright_admin"> © CAMELHORSE CREATIVE STUDIO 2013 </p> 
    </div><!--login_container--> 

    <?php } ?> 
</body> 
</html> 

請有人可以幫助我這個也是,如果有人認爲這可能是一個安全問題請指正一個問題?

My Login screen when i open the page or refresh

+2

你確定他們是不是由瀏覽器添加? – andrewsi

+0

這很可能是瀏覽器存儲它們;與您的PHP代碼無關。 – Spudley

+0

這是由您的瀏覽器而不是通過php代碼添加。 – bansi

回答

8

在輸入的結束把autocomplete="off"

例如

<input type="password" name="password" placeholder="Your Password" required autocomplete="off"> 

將持有人也可以填充,這樣你可以刪除

<input type="password" name="password" required autocomplete="off"> 

你可以也把autocomplete="off"中的表單標籤

2

默認情況下,autocomplete屬性設置爲「on」。關閉它將阻止瀏覽器顯示可能已存儲的其他值。我很確定autocomplete屬性在表單標籤中不起作用。裏面要編輯輸入標籤,放

autocomplete="off" 

更多信息here

相關問題