2

I have a password element which I use for signing in process. But, I get this weird username and password once the page gets opened !!

enter image description here

but the problem is when I don't user password element but only input I don't get this weird username and password, what should I do to make them blank?

Here's the code

    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>";

Can you help me??

1
  • 2
    It's stored in your browser's AutoComplete cache. If you're using Firefox, look at Preferences > Security > Saved Passwords. Also, you can save yourself the headache of escaping your double-quotes by using single-quotes with your echo. Commented Mar 30, 2011 at 22:16

4 Answers 4

5

This is your browser remembering the username/password you've entered in for your localhost site. This isn't to do with your html or php. To test, try it out in another browser that you have used to view the localhost site and see if it adds it to the form elements.

EDIT

Note, following kag's answer, you can add autocomplete=off to the form to prevent the browser from autocompleting.

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>
";

Also, consider not using tags like center and small; instead use css and classes/selectors.

Sign up to request clarification or add additional context in comments.

Comments

3

This is your browser trying to help you by automatically filling the fields for you. If you want to stop it from doing so, you can add autocomplete="off" in both <input>.

1 Comment

Isn't the autocomplete="off" thing just for the dropdown suggestions created once you start typing? Per link
1

Try adding the "value" attribute to the input tags and set it to empty:

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

If that doesn't do it, try using 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="" />

Comments

0

Try with:

<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 -->

and

<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 -->

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.