Retain values after POST
Moderator: General Moderators
Retain values after POST
I think this should be quite simple, but can't find any info on the Web.
I would like the values in textboxes to be retained if the users POST's them to the next page,
then presses the "Back" button in the browser to return to the previous page.
There is no sensitive data, usernames/passwords etc.
Thanks for any help
I would like the values in textboxes to be retained if the users POST's them to the next page,
then presses the "Back" button in the browser to return to the previous page.
There is no sensitive data, usernames/passwords etc.
Thanks for any help
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
That isn't controlled by PHP really. Only if the page actually fetches again can PHP really do anything about it. Their browser chooses whether to cache their form info or not (with some possible nudging PHP can do).
Read up on how PHP can affect the cache settings (hint: header())
Read up on how PHP can affect the cache settings (hint: header())
if u put the default value of the boxes as
Code: Select all
<?PHP echo '$_POST['watuwant']'; ?>-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
I don't think you quite get what (s)he wants to do. If you push back in most browsers, they have stored a copy of the page, and the copy would be the one without the text entered into the form.kyoru wrote:store them in session variables, and make sure the forms post the value if they exist?
The only way to do it is really what Feyd said; forcing no-cache. However, if that doesn't work, the only other alternative (alternative because it requires one extra step on the users' part) is to include a link on your form page that mentions "Lost data? Click <a>here</a> to attempt to recover it." which just reloads the page, in which you print out the session variables if they exist.