<p>I have <code>buy.php</code> with a <strong>form</strong> where you enter <em>items, quantity, shipping data, etc.</em>  </p>

<p>When you click the <strong>Submit button</strong>, it posts back to <code>buy.php</code> <code>($_SERVER['PHP_SELF'])</code> and does some data validation. </p>

<p>If there are fields missing or errors, they are highlighted. If everything is correct, I save the <code>$_POST</code> data in <code>$_SESSION</code> variables, then do a <code>header('Location: check.php')</code>, where I display the data so the buyer can check the info one last time before actually buying.</p>

<p>Now, if I'm in <code>check.php</code> and hit the Back button to <code>buy.php</code> so I can change stuff, the browser asks if I want to resend the POST data. I'm trying to avoid that. </p>

<p><strong>Anyone have any good advice or good practices for PHP Multiform validation?</strong></p>

<p><strong>Also, if I had n pages for the user to fill, <code>buy.php, buy2.php, ... buyn.php</code> before check.php would the same ideas still hold?</strong></p>

[{'answer_id': 55767, 'author': 'Glenn Slaven', 'author_id': 2975, 'author_profile': 'https://Stackoverflow.com/users/2975', 'pm_score': 3, 'selected': True, 'text': "<p>You could do a redirect to buy.php after saving to the session object, which then does a server redirect to check.php, it would mean when the user clicks back, they're going back to the GET request not the POST request</p>\n"}, {'answer_id': 11230741, 'author': 'FstaRocka', 'author_id': 1486271, 'author_profile': 'https://Stackoverflow.com/users/1486271', 'pm_score': 1, 'selected': False, 'text': '<p>Yes - I agree with above. I ALWAYS do a <code>redir</code> away from the last post, so clicking back bounces them back without that error OR re-submissions. it also avoids complications. u can always tag the <code>redir</code> link page with a <code>?m</code> or <code>&amp;m</code> (i.e.: <code>page.php?m</code>) and have this at top of page: (use <code>elseif</code> there after) </p>\n\n<pre><code>if (isset($_GET[\'m\'])) {\n  echo \'order placed.\';\n}\nelse {\n  //...\n}\n</code></pre>\n\n<p>You can have it all on one page too. Just name the submit buttons <code>submit1</code>, <code>submit2</code>, like: (bear in mind if you use an image for submits, it becomes <code>$_POST[\'submit1_x\']</code> :)</p>\n\n<pre><code>if (isset($_POST[submit1]) {\n  //validate + save session data from form1\n  //display form 2\n} else if(isset($_POST[submit2])) {\n  //validate + save session data from form2\n  //display form 3\n} else {\n  //display first form\n  //&lt;input type="submit" name="submit1" value="Continue"&gt;\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/55757', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2542/']