- This topic is empty.
October 18, 2012 at 9:30 pm #40364
Hey guys, I’ve made a PHP form that processes itself, that is, it is it’s own back-end engine. This is amazingly helpful when you just want to drop a PHP include in your page, say `` and be done with it, and not have to reference an engine or maintain more than one document. My contact forms used to be 5 documents, because I would have a default, success, error, form, and engine file to load dynamic content based on how the engine performed. This takes that same concept, and reduces all five of those files down to one form that you can include anywhere on your site. It’s completely functional right now, but I’m working on developing it further and improving it. If anyone would like to try it out, or would like to contribute, you can find it on [Github](https://github.com/NicholasRBowers/Self-Processing-PHP-Form).October 20, 2012 at 3:42 pm #112315
Great point @traq. This is definitely still a work in progress, and is in active development. I did some cleaning up that I pushed to origin right after you forked actually. I’ll make it a point to split up the two. I’m trying to walk the fine line of making it user friendly for non-coders and making it efficient. I’ll do some more cleaning up of the code and push changes to the repository so you can re-fork if you’d like.
EDIT: @traq I’ve rewritten the code to eliminate breaking in and out of PHP. Committed and pushed to Github. Next step will be to automate the building of the forms themselves, and getting rid of the hideous isRequired() function.October 29, 2012 at 7:01 pm #112904
@traq check out where I’m at now on it, I think you’ll be able to help out. I’ve laid the framework for automated form building, but not validation (because validation is inherently different depending on the type of field) – trying to find a way to make it anticipate the kind of data meant for each form.October 29, 2012 at 7:58 pm #112907
Okay, so I’ve created a self-processing PHP form that builds itself dynamically based on a configuration array.
$inputFields = array(
// Which fields do you want the contact form to include?
// FORMAT: array(referenceKey (no spaces), Display Name, fieldType, isRequired?),
array(‘name’, ‘Name’, ‘text’, true),
array(‘phone’, ‘Phone Number’, ‘text’, true),
array(’email’, ‘Email Address’, ‘text’, false),
array(‘source’, ‘Source’, ‘text’, false),
array(‘message’, ‘How can we help you?’, ‘textarea’, true),
I’ve hit a slight road block, as I’m not sure how I should approach dynamic validation of the data passed into the forms. Each field has different validation that goes further than just determining if a required field is blank (email address will be validated via REGEX differently than a phone number). I need a way to be able to validate many different types of input, without knowing explicitly what they are.
I can obviously use pre-fit reference keys (email for email address, name for name, phone for phone number, etc.), but that isn’t something that’s very user friendly, as that all has to be documented and places limitations on the code. For the complete code, you can visit [GitHub](https://github.com/NicholasRBowers/Self-Processing-PHP-Form). Ideas?October 31, 2012 at 10:45 am #113030
@traq thanks for your input! I’m changing things up right now, and I thought of a way to handle things thanks to what you said. I’ll let you know when it’s committed and pushed. I haven’t got a chance to look at your gist yet, but I’ll do that very soon.
Had a question about adding the header to the email though: if I add it do I have to change the returns in my body to carriage returns? and do I add these headers before the To: From: etc headers?
- The forum ‘Back End’ is closed to new topics and replies.