views:

68

answers:

2

I have a web app I'm building that has about 50 forms.

I have a very nice form-building class that handles the creation and submission of these forms very nicely and it's wrapped with error handlers, etc. No help needed there.

However, the forms are scattered through 120 pages. I could really use some weigh in from you guys about the ideal organization structure for these pages/forms. Here are some ideas. Both have pros and cons.

  1. Each page, in the header, creates the form there detects the presence of a $_POST['action'] variable and processes the forms there.

  2. Each form is built by a function in a form functions file and returns the form object when it's called in the header of the page, and when processing, since $_POST is a superglobal the processing functions is called in the header of the page as well.

  3. For each page such as profile.php include a file in the header that includes a profile.forms.php in which the method #1 or #2 above happens.

Ideas?


Just a note, there will rarely be more than one form per page.

+1  A: 

Go for 3. - it will be easier to maintain the code later than to change 120 pages one by one.

Skuta
A: 

Skuta I appreciate your help. I ended up using #2 and after fleshing out the entire project I was extremely happy with the results. It was flexible and consistent in its implementation and I was able to easily bring on other coders to the project with a minimal amount of training.

jerebear