0

I am having a problem with firefox and a form web page. The same problem does not occur with chrome. When the user submits the form with required fields empty an error page is shown with a "go back"-button. If the User goes back the form is empty in firefox.

Now I want to ensure that this does not happen. I found this code: How to keep changed form content when leaving and going back to HTTPS page? (works with HTTP)

But I do not understand how to get it working.

I also found this Mozilla Firefox form values reset on history.back

Which is basically a copy of my question, but I need a full working example of the proposed solution "capture your POST data and turn it into SESSION variables, then repopulate input fields on browser back".

Here a webpage for testing that show the code in use: http://s659173456.online.de/

However it does not show the problem in firefox nor chrome. Nevertheless I want to include a restorage of the input values using session variables.

EDIT: I added a session restorage:

<?php session_start(); ?>
....
<input class="flatinput" type="text" size="40" name="Nachname" 
    value="<?php echo (isset($_SESSION['Nachname']) ? $_SESSION['Nachname'].'restored' : ''); ?>"
/>

and in the php file for the evaluation

function process_anmeldeformular() { 

// save POST as SESSION
if(isset($_POST)) {
    foreach ($_POST as $key => $val) {
        if( ($val != "submit") && !empty($val) ) {
            $_SESSION["$key"] = $val;
        }
    }
}

But that does not solve the problem.

Matthias Pospiech
  • 3,130
  • 18
  • 55
  • 76
  • The accepted answer on the first question you have linked provides several options with pros and cons, all the code for each one and working jsfiddle examples. – miknik Nov 15 '17 at 20:41
  • And I included the code and it is not working for me... – Matthias Pospiech Nov 15 '17 at 20:48
  • If you had provided a simple example that works in Chrome, and not in Firefox, then we would have had something to work on. Now I don't really know how to help you. – KIKO Software Nov 15 '17 at 21:04
  • I created a dummy site for the code, but it does not show the problem in contrast to the real site. Nevertheless I want to restore the session variable in this code. Link added to the question. – Matthias Pospiech Nov 16 '17 at 19:41

0 Answers0