When you have a simple form, let's say a contact us form do you usually:
A) Make 2 pages, one with the html form and another page to handle the form data
or
B) Keep it in one page, output a hidden value into the html form, upon loading of this page we check if the hidden value has been set, if not we output the html form, if the hidden value has been set we run the portion of the code that handles the form.
What about multipart forms?
Do you tend to have:
A) form1.php form2.php form3.php form_handler.php
or do you tend to go with the:
B) form.php?part=1 form.php?part=2 form.php?part=3 form.php?part=process?
(but with post variables of course)
I usually opt for option B especially with multipart forms, just so I don't have a huge amount of php scripts sitting around. The only time I opt for A is when the form handler calls for very large amounts of code, it's just easier to have it in it's own file in some cases.
Share your methods / opinions
forms and form handler, multiple pages or one?
Moderator: General Moderators
All my forms submit to themselves, and check a hidden variable to see if they should handle the form input. Multipart forms do the same, and use header("Location: part2.php") type things to travel from one section to the next. It's just the way I've always done things, it encapsulates everything for each form in a single script.
There are some good comments on this here:
viewtopic.php?t=9775
Looking at bout 4 different form handling models.
viewtopic.php?t=9775
Looking at bout 4 different form handling models.