Page 1 of 1

go back to a page retaining the previous values

Posted: Fri Feb 03, 2006 10:40 am
by Enga
Hey!

I was creating a form when it does the some database validation i want do display a back button.
The ideia was to mantain all the values previous filled. I thought this would work if i just did the following:

Code: Select all

<form>
<input type="BUTTON" name=" back" value="back" onclick="javascript:history.back()">
</form>
the thing is that this doesnt solve my problem i manage to get back to the previous web page but with all forms in blank :(

anyone knows how to solve this?

Thanks

Posted: Fri Feb 03, 2006 10:51 am
by Chris Corbyn
http://php.net/session :)

If you search this forum for "sessions" you should find some useful threads ;)

Posted: Fri Feb 03, 2006 11:10 am
by Enga
thanks d11wtq!

I went to http://php.net/session and found the answer. :D

Here it goes for anyone with similar problems.
Quote from the site:

Ming:
if you are dealing with forms and session_start() you might experience that all form-values will automatically be emptied after returning to the form with the browser's back-button or javascript's history.back().

this is especially annoying if you want to enable your users to use the browser's back button to apply corrections to the inputted data on the previous page.

add this line right after calling session_start() to solve the problem:

Code: Select all

header("Cache-control: private");
now, users can hit the back-button to access the form containing all the information they've inputted before.