Monday, January 28, 2008

Maintaining 3 forms in 1 with PHP and javascript

Hi,
I'm working on a project that requires a registration screen. I'm currently using PHP, MySQL, Apache running on Linux (PMAL)... LAMP. My development is on Windows. Ok. The Registration screen supports maintaining a "running" list of entered information. Multiple contact addresses and emergency contacts. I'm not a Graphics Designer but i think i can transition from being a paper artist to a digital one. Before I get to adding graphics, I want to include all functional requirements.

The three forms are available at any time. They are "hidden" in html via style="display:none;" and maintained by javascript I actually used no tables for the interface which i'm proud of. I did read The Art & Science of CSS, and now I'm encouraged to try to adopt some of the techniques outlined in the book, and the chapter on forms was interesting. I switch forms by setting the attribute display:none/block for the form that i need. I have a utility function that clears the current form. I also have other utilities that read the form as well.

Each time the user clicks on the link to persist the entered information I add it to a server side object written in PHP with the same name. Then i clear the form and wait for further input. The persisted information is shown in summary to the user in three different tables on the right side of the screen. Each table represents a PHP object. The table gives the user a visual clue as to how many different records were persisted. The list allows the users also to add and delete a record from the list.

All the information captured from the user will be persisted in the MySQL database when all the registration's minimum requirements are met. Final validation of passwords complete the registration process.

The main components of the registration screens are:
  1. registration.php - presentation
  2. registration.js - javascript related to presentation also contains all ajax methods as well
  3. registration-submit.php - handles final form validation and persistence to database
  4. registration-sucess.php - presentation and confirmation of successful registration
  5. Datasource.php - object to persist the database connection
  6. Object1.php - model - represents one record in the 1st & 2nd, javascript list (records types are saved)
  7. Object2.php - representes one record in the 3rd javascript list.
  8. config/dbconfig.php - contains the database information
  9. config/sysconfig.php - contains specific file system related information for file upload

No comments: