go back to a page retaining the previous values

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
Enga
Forum Newbie
Posts: 8
Joined: Mon Nov 21, 2005 6:17 am

go back to a page retaining the previous values

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

http://php.net/session :)

If you search this forum for "sessions" you should find some useful threads ;)
Enga
Forum Newbie
Posts: 8
Joined: Mon Nov 21, 2005 6:17 am

Post 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.
Post Reply