The reason that inputted data is missing is because when the back button is pressed the browser has to reload the previous page. This means it reads the source code and returns to the default state prior to the inputting of any data so hence the form elements are empty.
Sometimes you will use a website and this wont happen and when you press back the form values are still in place yes? Well this is because the developer is using some server side programming to remember the values you enetered in the form and repopulate the form fields with these values.
Essentially what is happening is the first time you visit the page the server looks to see if it has stored values for any of the form elementsa you may have already filled in. If it doesnt they appear blank. Then you fill in the form and hit submit/next. The values you entered in to the form are stired in variables and if you then go back to the form in the same session then those variables will be used to populate the form with your previous entries.
This can be done with any number of serverside solutions depending on the site hosting including ASP, Perl, JSP, PHP etc. It could also be achieved entirley client side using cookies or querystrings but this is far less common.
Sometimes I do recreate the form and repopulate the form fields with corresponding values after form validation has found missing or incorrect fields and sometimes I use an Alert text saying to push the back button to go back to the form.
I am pretty certain that NOT always the page is completely reloaded and the form input is gone as I use it a lot without problems. The form is displayed the way the user filled it in except form password fields and file fields which will both be empty.
Now, however in the project I am working on there is a certain procedure where I have this problem that the form has become completely reset consistently after going back to the page with a button using "window.history.go(-1)".
What is causing this, in which situation will it give problems as my experience is that the 'go back' procedure works fine normally?
The html is embedded in a PHP script that uses the session function.
When the session_start() function at the top of the page is removed I don't have the problem with the blank form fields. I guess this is done for security reasons.
As removing the session_start function is no option I guress there is no other solution then what crazyboybert suggested.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.