2011-03-30 46 views
2

我有一個用於登錄過程的密碼元素。但是,一旦頁面打開,我會得到這個奇怪的用戶名和密碼!密碼輸入元素問題

enter image description here

但問題是,當我不知道用戶密碼元素,但只有輸入我沒有得到這個怪異的用戶名和密碼,我應該怎麼做才能讓他們的空白?

下面的代碼

echo" 
    <center><small> 
    <br /> 
    &nbsp; &nbsp; 
    <p> Welcome Guest you can sign in here:</p></br> 
    <form action = \"HomeWork.php\" method = \"post\"> 
    User name*: <input type=\"text\" name=\"Username\" /> 
    Password*: <input type=\"password\" name=\"Password\" />&nbsp; 

<a href=\"Signup.php\">or Sign up !</a> 
     <br /> <br /> 
     <input type=submit value=Submit align=\"middle\" /> 
     </form> 
     </small></center>"; 

你能幫助我嗎?

+2

它存儲在瀏覽器的「自動完成」緩存中。如果您使用Firefox,請查看「首選項>安全性>保存的密碼」。此外,通過在echo中使用單引號,您可以節省您擺脫雙引號引起的頭痛。 – drudge 2011-03-30 22:16:49

回答

5

這是您的瀏覽器記住您爲本地主機站點輸入的用戶名/密碼。這不是與你的HTML或PHP。要進行測試,請在另一個瀏覽器中嘗試使用它,以查看本地主機站點是否將其添加到表單元素。

編輯

注意,以下KAG的回答,您可以添加到autocomplete=off的形式,以防止自動填充瀏覽器。

https://developer.mozilla.org/en/how_to_turn_off_form_autocompletion

echo " 
<center> 
<small> 
    <br /> 
    &nbsp; 
    <p>Welcome Guest you can sign in here:</p></br> 
    <form action='HomeWork.php' method='post' autocomplete='off'> 
    Username*: <input type='text' name='Username' /> 
    Password*: <input type='password' name='Password' />&nbsp; 
    <a href='Signup.php'>or Sign up !</a> 
    <br /> 
    <input type='submit' value='Submit' align='middle' /> 
    </form> 
</small> 
</center> 
"; 

另外,考慮不使用標籤,如centersmall;而是使用CSS和類/選擇器。

3

這是您的瀏覽器試圖通過自動爲您填寫字段來幫助您。如果您想停止這樣做,您可以在<input>中添加autocomplete="off"

+0

剛開始輸入時創建的下拉建議是不是autocomplete =「off」?根據[鏈接](http://www.htmlcodetutorial.com/forms/_INPUT_AUTOCOMPLETE.html) – Dave 2011-03-30 22:25:35

0

嘗試用:

<meta http-equiv="Pragma" content="no-cache"> 

<!-- Pragma content set to no-cache tells the browser not to cache the page 
This may or may not work in IE --> 

<meta http-equiv="expires" content="0"> 

<!-- Setting the page to expire at 0 means the page is immediately expired 
Any vales less then one will set the page to expire some time in past and 
not be cached. This may not work with Navigator --> 
1

嘗試添加 「值」 屬性輸入標籤並將其設置爲空:

<input type="text" name="Username" value="" /> 

如果沒有按」不要這樣做,請嘗試使用javascript:

<head> 
    <script type="text/javascript"> 
     function clearMyFields() { 
      document.getElementById('input_u').value = ""; 
      document.getElementById('input_p').value = ""; 
     } 
    </script> 
</head> 
<body onload="clearMyFields();"> 
    <input type="text" id="input_u" name="Username" value="" /> 
    <input type="password" id="input_p" name="Password" value="" />