suggestions wanted concerning form handling "template"



OK, I am devising a php page that will handle a form submission, and
wanted to know if anyone has already setup such an idea, or if you had
links to point to good tutorials on this.

Basically I have a form (which I use smarty templating to display, and
smartyvalidator to validate).

The php page basically is driven by the action variable (add,
add_confirm, edit, edit_confirm, view, delete). When the form starts
out, it is in view mode. Then if you click the add button, it switches
to add mode. Confirming a new addition sends you into add_confirm
(which would write to a DB, etc.). Edit would work the same way, except
edit mode would lookup a record to display, edit_confirm would update
that record, delete mode would delete, and view mode would basically
display data (to edit/add/delete).

Sounds easy, but my code is pretty long and I am looking to simplify
this idea. Looking for how you all do this, and if anyone has a
"template" setup to do this.

Mine would be something like:

if ($action == "view") {
// do something

..... etc ....

Ideas? Let me know. Thanks,
Jim

.