资源说明:Generic php form processor designed to work easily with most forms
h1. Catch-All PHP Form Processor Catch-all PHP Form Processor is a two file PHP script that can capture virtually any form sent to it. It is intended for contact and registration forms of which the results need to be emailed to one or more parties. This script is not intended for file uploading or database communication. It can be used on almost any site with just about any form 100% free. h2. Credits Developed by Erik Reagan, http://erikreagan.com h2. Introduction Through my work in web development I've noticed the high number of times I need to write out a contact or registration form for a client. Each time I get the form fields together and then decide how I want to process the form. This usually entails a client-side validation of certain fields (required fields, email validation, etc) and then a back-end check of those fields before processing them. This process can get pretty repetitive if you do a high volume of projects or sites needing this function. I was looking for a way to process any form I create with the same script each time and thus produced this PHP script. It's a lightweight, single file form processor (with an additional file for configuration) that has a number of options. The goal of this script is to provide a small footprint resource available to use over and over. For certain forms you may want to implement your own client-side validation of fields before sending them to the form processor. Let's explore the features: h2. Requirements * This script requires PHP 4.0.7 or newer h2. Features * A PHP file inspects form data and runs simple validation on empty fields and email addresses * You have the option of sending the user to a Review page * Upon review the user can print and/or submit the results once all fields are * Can submit results to 1 or more email accounts * Can send a blind carbon copy (bcc) as well * Email results can be plain text or HTML formatted * Script can be used in a standalone environment OR as a part of your existing site template * You can define which fields are required * You can define which fields (if any) should not be displayed back to the user when they check the results before submission (eg: IP address) h2. Form Field Compatibility This script successfully processes the following field types: * text * radio * checkbox * select & options(single and multiple) * hidden * textarea * image Be sure to read below to understand how to successfully setup multiple checkboxes within a single "name" and multiple select options within a single "name". h2. Setup & Customization - THE FORM h3. The Basics Catch-All Form Processor is nothing but a processor. The form code must be provided on your end. This script does a few things that require you to put a little bit of thought into your form. For every input field you have you must give it a name (a standard in XHTML). How you name said fields will determine how they are displayed in the results. I have followed the standard of "pretty links" all around the web now. If you have a field such as "First Name" you would (probably) want to name it "first-name" or "first_name". This is processed in the script to read "First Name". For example:This will be read by the script as the field "First Name" having a value of "Erik Reagan"This will be read by the script as the field "Additional Comments" having it's relative value h3. Form Submission **THIS IS VERY IMPORTANT!** In order for the script to process the form it must recognize the submit button. Your submit button must have the name set to 'submit' to work. Image submit buttons are also acceptable as long as you give them a value of 'submit' AND give them a name.The above is acceptable The above is acceptable The above is acceptable The above is NOT acceptable (name="something" is missing)h3. Require Fields If you have fields you need to require (such as name, email, etc) you can simple append "require" to the FRONT of the name. For example:This will alert the user if they have left a required field blank. I would suggest showing the user that the field is required by marking it somehow in your form Requiring ainput is a bit different. To do this you'll need to adjust the name from something like 'cars[]' to 'required-cars[]' and then add an option similar to this:
You can put anything you want in the 'Choose One' area. This will require the select to be used. You can read more about the select usage below. h3. Ignore Fields Many times developers use hidden input values during form submission. Another common factor (mostly seen in registration forms) is a terms and conditions text area. When filling out forms of this nature you typically do not want the user to 'review' this information. To hide these fields from the users review you can simply add "ignore" to the FRONT of the name. For example:The script breaks down this name as "Terms and Conditions" and does not display it to the user. Ignored fields are, however, included in the emailed results. h3. Email Validity Any field name with the string 'email' in it will be flagged as needing to be a valid email address. The standard regular expression is used to check for this validity. For example:The script will flag this field as needing to validate as an email address because it sees 'email' in the name. It will display as "Email Address"The script will flag this field as needing to validate as an email address because it sees 'email' in the name. It will display as "User Email" because the hyphen is treated like every other hyphen and is replaced by a spaceThe script will NOT flag this field as needing to validate as an email address because there is no full string of 'email' in the name h3. Form Method & Action In order for this script to work without tweaking the core of the php the method of the form must be POST. For example:
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。