Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Keep form contents when back button is pressed?

Options
  • 06-07-2008 10:47pm
    #1
    Closed Accounts Posts: 12,382 ✭✭✭✭


    Hello

    This relates to the website tempjobs.ie

    If a user picks a region, enters a name, phone number, e-mail address and cover letter, but no cv, and then submits his application, if he presses the back button everything he typed is remembered.

    However if he had included his cv when submitting his application, when he presses the back button all the form contents are blanked.

    Is there anyway to get around this so the form contents are remembered whether or not he attached his cv?

    Thank you!


Comments

  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Yes, store the entered data in to a session upon posting the form, and then set the fields default values to be the sessions which are remembered after the back button is presssed.


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Mirror wrote: »
    Yes, store the entered data in to a session upon posting the form, and then set the fields default values to be the sessions which are remembered after the back button is presssed.

    Pressing the back button may not end up in a round trip to the server though, so I don't know if session variables would be accessed.

    I imagine the problem with the file input type is some sort of security measure?


  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    Yeah, the input type gets blanked to prevent the website owner from changing it to upload a different file.

    I thought about the session idea, but the fact that the form contents only get blanked if they include something in the file upload box is a bit puzzling...


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    dublindude wrote: »
    Yeah, the input type gets blanked to prevent the website owner from changing it to upload a different file.

    I thought about the session idea, but the fact that the form contents only get blanked if they include something in the file upload box is a bit puzzling...

    Does this happen in Firefox and IE? I might have a quick go here when I get a chance.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    I'd still give the session idea a go, if you think about it, you have your form with inputs like [php]<input type="text" name="first_name" value="<?= $_SESSION; ?>" />[/php]

    and then when the submit button is pressed you get to your processing page, and at the top of that you set [php]$_SESSION = $_POST;[/php] etc. for each field, or store them in a session array. Then as long as you have session_start(); at the top of both the form page and the processing page, those sesisons are kept alive, as session variables are intended to be, regardless of the users navigation, because the sessions are set even before the processing page is output i.e. the script always gets past the point where the sessions are set, regardless of whether a file was uploaded or not.


  • Advertisement
Advertisement