[thelist] PHP - centralised processing for multiple forms

Paul Bennett Paul.Bennett at wcc.govt.nz
Tue Sep 5 18:39:29 CDT 2006

Thanks to those who replied to this thread - using my thoughts and your input I think I've come up with a workable solution:

1. Form page is simple HTML with small amounts of PHP code for setting validation data*
2. function page is included which controls session setting, validation and flow (eg > form render > form errors / 'thank you' page > printable page
3. one line php snippets control rendering of error messages or confirmation messages eg: <?php errorMessage(); ?>

The only obstacle I have to overcome is replacing the form with the thank you data when submission has been successful. Seeing as I'm trying to keep things contained in one file (using includes only) I don't have access to xslt (or do I?). I can replace content using DOM, but want to have a solid fallback using a non-js solution. I'd rather avoid having if / else statements amongst the html code as I'm trying to keep this solution as clean as possible.


* Validation data is set like this - any comments? 

$fields = array(
		'name' => 'required=yes valid=textNum type=text maxlength=100', 
		'address' => 'required=yes valid=textNum type=text maxlength=100',
		'age' => 'required=no valid=under20|20-29|30-39|over40 type=radio',
		'sane' => 'required=yes valid=yes|no type=checkbox',

 I figure this is easy for html coders to set and I can just split the strings at the ' ' , '=' and '|' chars to get the values. This avoids any validation setting being seen or altered by the client, which was one of my big security concerns

More information about the thelist mailing list