Search code examples
javascriptcssformsbackbrowser-history

Using javascript:history.go(-1) works but I lose css properties and scripts


When my clients submit a form and get an error they're taken to a page with a link to go back. I'm using javascript:history.go(-1) to go back to the form.

I'm loosing my css functionality with background changes and colors, etc. of the form when the client goes back.

I don't want the client to have to re-type everything agian with a refresh.

Is there a way to avoid this?


Solution

  • Why don't you save all the Data entered in the PHP Session, and (instead of history.go(-1)) Place a link to the Form again, where you check if there are values in the session, and write them in the Form-Field with PHP?

    Something like

    $_SESSION['name']=$_POST['name']
    

    and backwards..

    You could even do that without showing an error Page, and displaying the error on the form itself...