Page 1 of 1

Previously entered form data is re-entered automatically

Posted: Tue Dec 22, 2009 3:14 pm
by JackD
I have the code:

<div id="Search_Form">
<form method="post" name="Keywords" >
<p class="style1">Search For: <input type="text" name="KWs" style="width: 354px" /></p>
<p><input type="submit" value="Search!" /></p>
</form>

if ($_POST[KWs])
{ echo "Find: " .$_POST[KWs] . "<br />"; }

If I enter the page and type in a value for KWs, the next time I return to the page, the value for KWs is automatically applied rather than starting over with a "clean" form. I have tried unsetting $KWs and putting value="" into the form, but nothing seems to keep it from entering the previous text automatically.

Is there a way to always force a "clean" start?

Re: Previously entered form data is re-entered automatically

Posted: Tue Dec 22, 2009 7:00 pm
by McInfo
This appears to be a result of using your browser's back button. Remembering your form inputs is a "feature" of your browser that is related to the page history.

To fill the form with its default values, you can include a reset button (<input type="reset">) in the form or you can request the page again through a link or by entering the URL manually.

Using JavaScript and the onload event is not an option because in some browsers (Firefox) the onload event does not fire when returning to the page via the back button (it does in Internet Explorer, though). The onunload event is not an option either because the form would be cleared before it is submitted.

Edit: This post was recovered from search engine cache.

Re: Previously entered form data is re-entered automatically

Posted: Fri Jan 01, 2010 11:12 pm
by JackD
Sorry for this post, guys, it turns out it was the browser cache causing the problem. When I clear the cache, it no longer is a problem.

Thanks for tolerating a newbie.