A server side scripting language allows you to create dynamicweb pages. Web pages that have been enabled with PHP aretreated just the same as any other HTML page, and PHP even letsyou create and edit them the same way you would create and edityour HTML pages.
This PHP form consists of 3 web pages, an html page, a PHP page(PHP script) and a thank you page. You collect the visitorsinformation when he fills out the form on the html page. It isthen processed by the PHP script which resides on the server.The visitor automatically receives a "thank you forsubscribing" message. The form results are returned from theserver to your email box.
Check with your web host you have PHP4 installed on your server Most Unix servers do - if so you are in luck and ready to go.
How to create the simple PHP form
You will create a very simple, effective form in which you will collect the name, email address and comments of your visitors. The form results will be sent to your email address. Here's the Simple PHP Form in action.
1. Download the PHP script - once downloaded, copy and paste the PHP code of Jack's FormMail.php script into notepad (not MS Word) and save it as securemail.php (not formmail.php - this will make it a more secure form)
http://www.dtheatre.com/scripts/formmail
2. Edit Recipient Field - the recipient field allows you to specify to whom you wish for your form results to be mailed. For Multiple Recipients separate the email addresses with commas (",").
$recipient = "info@domain.com, steve@domain.com";
Note: If you use this option you cannot use recipient in your html form i.e.
If you already inserted this in your html form, then simply delete it. This will prevent spammers from harvesting your email address because it now can't be found on your html form.
3. Edit the referrers field - the only recommended field to edit in the script is the "referers" field. This field defines the domains that allow forms to reside on and use your securemail.php script. If you try to put the form on another server, that is not the specified domain or ip, you will receive an error message when someone tries to fill it out.
"subject field" - this allows you to specify the subject that you wish to appear in the e-mail that is sent to you after this form has been filled out. If you do not have this option turned on, then the script will default to a message subject: "Form Submission".
ie:
"full name field" - this allows visitors to fill in their name. This will help you to personalize your return email by including their first and/or last names.
i.e:
"email address field" - this allows you to specify your return e-mail address. If you want to be able to return e-mail to your user, I strongly suggest that you include this form field and allow them to fill it in. This will be put into the From: field of the message you receive. The email address submitted will be checked for validity.
i.e:
"comments field" - this allows visitors to add any comments in your form. You could name this field anything you like.
ie:
"required field" - these are the required fields you want your visitors to fill in before they can successfully submit the form. If the required fields are not filled in, the visitor will be notified of what they need to fill in, and a link back to the form they just submitted will be provided.
ie:
"redirect field" - if you wish to redirect the visitor to a different URL, rather than having them see the default response to the fill-out form, you can use this hidden variable to send them to a pre-made HTML (ie thankyou.htm) page.
"submit field" - this allows the visitor to submit the form
ie:
8. Create a thank you page (thankyou.htm) - this web page will automatically thank visitors for subscribing. Add your own comments you wish them to receive. Upload this web page to your server.
Tip: Use your own domain name, email and IP address in the fields above.
Here's an example of a typical web page using the PHP form. (http://www.ihost-websites.com/contact.htm)
All the fields are included as was discussed above: /*
*/ 9. Copy and paste this html form into your web page - name it anything you like (ie contact.htm), then upload it to your server.
10. Test out your form - when you fill out the form, you should immediately receive the reply from your thankyou.htm page and receive the form results in your email box.
Conclusion - you now have a fully functional and flexible PHP form on your web site to collect visitor information. You can add more fields to the form if necessary. You may also add any number of HTML forms to your web site and still use the same PHP script.
Some rights of this page's plain text stuffs are reserved for the author.
The template is generated via PsycHo, modified and optimized by BloggerO and is Licensed.