PHP-form preview before submission to database?


I can get my data into the database from a form and even edit my database info. What I’m looking to do, now, is to setup an intermediate page where the submitted info is displayed to the person entering the info. The submitter can then go back to the form entry to edit their submission or click an OK button to add it to the database.

What is the best way to get the data from the data entry screen to the verification screen, then on to the actual database insert function?


Using the forms post method automatically forwards the data from the form to the next PHP page. All you have to do is reference each form field with is PHP equivalent (i.e. name = $name).

Use different names for the submit buttons (submit1, submit2, etc), and determine which was pressed like this:

if (isset($submit1) && !isset($submit2) && !isset($submit3)) {
do stuff

If you’ve determined that the’ve entered their info and it is to be previewed, simply store it in hidden HTML form fields inside the FORM tag:

<input type="hidden" name="email" value="<?php echo("$email"); ?>">

Hope that helps a bit. :slight_smile:

Dang, Wayne just beat me. :slight_smile: He, however, still needs to be able to submit the information via the button, so in that case the hidden form fields would probably be the way to go. I could be mis-reading him, but I think that’s what he means.

If I’m wrong, let me know! :slight_smile:

OK that’s prettymuch what I thought. So, to keep it simple, I should just add an intermediate page that has the input results visible AND hidden form fields holding them that then submits to the final processing page.

I was hoping there was a simpler way to do it, but it should only take a half hour or so per form…



Yeah, not terribly convienent, but the only way I know how, and I’d imagine it’s the most commonly used. Good luck with your work! :slight_smile:

If you haven’t started yet, you could probably do a simple display and simple hidden input using while loops in about 6 lines of code.

while(list($key,$val) = each ($HTTP_POST_VARS)) {
if($key != “submit”) {
print $key ." = “. $val.”<br>“;
printf('<input type=“hidden” name=”%s" value=“%s”>', $key, $val);

Duh - I should’ve thought of that. :slight_smile: Very nice work Freddy - in my book, you’re Mr. Efficiency. Slogan? “There’s always a better way!” :slight_smile: