3

I'm writing a PHP script. I've got a form uses post method and action to another page. If an error occurs, I show a message on that target page, and let the user go back via a link that triggers history.back(); javascript function. So user clicks that link and turns back to the page includes form and values entered by user should remain in inputs.

They stay on Chrome, but lost in Firefox. Is there a way to keep DOM information on all major browsers using history, or is the only way to do that is to use a cache like session, cookies, etc. ?

Aycan Yaşıt
  • 2,106
  • 4
  • 34
  • 40
  • 1
    Do you have permissions to modify the form? If so you would suggest to submit the form to the same page. In case of error you can open the same form with prefilled inputs and error message. If validation succeded redirect the user to the next page. – claustrofob May 21 '13 at 08:04
  • 1
    why don't you add validation on that page to avoid errors? – Davor Mlinaric May 21 '13 at 08:04
  • I've already implemented various pages in my script in this bad way. So if there is a simpler solution, I don't want to change the form submitting attitude on all of those pages. – Aycan Yaşıt May 21 '13 at 08:35

1 Answers1

1

You could, and I know it's annoying, capture your POST data and turn it into SESSION variables, then repopulate input fields on browser back.

Alternatively, You can submit the form to an iframe and process, or use ajax to process and depending on the result, trigger a new page load or not.

Gary Hayes
  • 1,728
  • 1
  • 15
  • 23