[thelist] PHP - centralised processing for multiple forms
Paul Bennett
Paul.Bennett at wcc.govt.nz
Thu Sep 7 17:11:32 CDT 2006
Thanks der wert,
Sounds like you've come up with quite the nifty solution :) well done.
For our needs, we need full control of the initial HTML. There's enough variation in the forms across the site to justify hand building each form.
I'm 80% of the way to a workable solution myself which is a variation on the system you've set up.
Keep that code around - I guarantee you it will come in handy :)
Paul
-----Original Message-----
From: thelist-bounces at lists.evolt.org [mailto:thelist-bounces at lists.evolt.org] On Behalf Of der wert
Sent: Thursday, September 07, 2006 8:54 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] PHP - centralised processing for multiple forms
Hi Paul, sorry for the delay when I first saw your email I started coding
which I tend to do sometimes, the result I think is nifty, what I've created
isn't finished but it's at a pretty good stage.
what I created what a single php file that includes a conf file of form(s)
to be created
the config file uses an array to store the configuration of the form to be
generated
here's an example of a one of these config arrays
$form['1']['fields']['Name']['input']=true;
$form['1']['fields']['Name']['regex']='[a-zA-Z ]{1,12}';
$form['1']['fields']['Number']['input']=true;
$form['1']['fields']['Number']['type']='hidden';
$form['1']['fields']['Number']['regex']='[0-9]{1,12}';
$form['1']['fields']['Number']['value']=123;
$form['1']['fields']['Password']['input']=true;
$form['1']['fields']['Password']['type']='password';
$form['1']['fields']['Password']['regex']='[0-9A-Za-z]{1,12}';
$form['1']['fields']['Email']['input']=true;
$form['1']['fields']['Email']['regex']='[a-zA-Z0-9_.]{1,20}@[a-zA-Z0-9_.]{5,20}';
$form['1']['fields']['Phone']['input']=true;
$form['1']['fields']['Phone']['regex']='[0-9+-]';
$form['1']['fields']['Zipcode']['input']=true;
$form['1']['fields']['Zipcode']['regex']='[0-9]{5}';
$form['1']['fields']['Sex']['choices']['M']='M';
$form['1']['fields']['Sex']['choices']['F']='F';
$form['1']['fields']['Sex']['value']='F';
$form['1']['fields']['Sex']['regex']='[MF]{1}';
$form['1']['fields']['Other']['textarea']=true;
$form['1']['fields']['Other']['regex']='[\w\s]{1,32}';
$form['1']['fields']['Gender']['radio']['M']='M';
$form['1']['fields']['Gender']['radio']['F']='F';
$form['1']['fields']['Gender']['value']='F';
$form['1']['fields']['Gender']['regex']='[MF]{1}';
$form['1']['fields']['Send']['input']=true;
$form['1']['fields']['Send']['type']='submit';
$form['1']['fields']['Send']['value']='Send';
$form['1']['action']['confirm']=true;
$form['1']['action']['emailto']='form at example.com';
$form['1']['action']['type']='POST';
you can also choose if you want XHTML or HTML to be generated
what you do is put arrays for the forms in the config file
then in order to put a generated form on your page you would do like so
example.php
<?php
require_once('./header.php');
define('_form', '1'); //this tells it to generate form 1 from the config
file
require_once('./quickforms.php'); //the file that does all the hard work
require_once('./footer.php');
?>
a picture of the end result with a css style sheet applied is as follows
http://tinyurl.com/z6tfn
the form input is determined to be valid or not according to the regex in
the conf file
the point of the project is to the point where you submit the form then it
displays if the data entered was valid or not according to the regex, I've
been busy with school and work so that is why it is not finish as of now,
but I still like the turnout so far, let me know if you'd like the code or
not
D
_________________________________________________________________
Get real-time traffic reports with Windows Live Local Search
http://local.live.com/default.aspx?v=2&cp=42.336065~-109.392273&style=r&lvl=4&scene=3712634&trfc=1
--
* * Please support the community that supports you. * *
http://evolt.org/help_support_evolt/
For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !
More information about the thelist
mailing list