Reputation: 3181
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 !!
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 />
<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\" />
<a href=\"Signup.php\">or Sign up !</a>
<br /> <br />
<input type=submit value=Submit align=\"middle\" />
</form>
</small></center>";
Can you help me??
Upvotes: 2
Views: 441
Reputation: 49198
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 />
<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' />
<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.
Upvotes: 5
Reputation: 29121
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="" />
Upvotes: 1
Reputation: 396
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>
.
Upvotes: 3
Reputation: 1700
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 -->
Upvotes: 0