Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Data on Back Button

Status
Not open for further replies.

ronnyjljr

IS-IT--Management
Nov 23, 2003
249
US
Hiya,

Is there anyway to prevent the data in the form fields from being lost if the page refreshes or the user hits the back button? Everytime I check the data for validity it will display the error but all of the form data is gone. Is there a quick solution or do I have to go through and essentially echo the form data values?

Thanks,
Ron

cout << "If you don't know where you want to go, we'll make sure you get taken";
 
in your form creation add a value in the value attribute that equates to the variable. confused?

eg.

instead of
Code:
<input type="text" name="textfield1" />

go for
Code:
<input type="text" name="textfield1" value="<?=$_POST['textfield1']"/>

if the $_POST var is not set you may get a notice in your error log but the user will not see the error if you have error_reporting set to a normal production value.

 
Haha,

This is what I wanted to avoid, explicitley setting the values but I guess it's the only way. I was hoping maybe I could set a browser variable and have it keep track.

Thanks though!
-Ron

cout << "If you don't know where you want to go, we'll make sure you get taken";
 
some browsers refill the forms if you press back. but there is no "standard" here. i always use the method above.
 
Didn't want to write the code :p haha

cout << "If you don't know where you want to go, we'll make sure you get taken";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top