Web Development: February 2008 Archives
Auto Form Mailer is an easy to use and powerful PHP script that lets you manage even the most complex of HTML forms and have them mailed to your email address. This script assumes zero knowledge of PHP to have it working for you. It handles unlimited form fields, you can set which fields are required and which fields need to have email validation applied to them.
This auto form mailer script is pretty simple to use. All the required files are in the 'files' folder in the download package. You DO NOT have to worry about what is happening inside of the 'fm.php' script. If you are a PHP pro, then you can always fiddle around with the scrip itself, but otherwise you don't really need to.
Okay, so what you have to do is, make the right changes in your HTML form. A demo HTML form is included in the package but the following documentation helps you if you are a totally dumb human being like me:
In your HTML form, make sure the 'action' attribute is pointing to the 'fm.php' script and the post method of form submission is being used:
<form method="post" action="fm.php">
Along with that, make sure your form has the following four hidden form fields:
<input type="hidden" name="email_subject" value="Feedback from your website">
<input type="hidden" name="email_sender" value="webmaster@yoursite.com">
<input type="hidden" name="email_recipient" value="you@yoursite.com">
<input type="hidden" name="email_thanks_url" value="thanks.html">
The first one (email_subject) is the subject of the email message that you'll get when the form is submitted.
The second hidden field (email_sender) will have the email address that tells you from where the email is sent, usually its your site's email address such as webmaster@yoursite.com.
The third one is the email address where you want to actually receive the email message when the form is submitted. This should ideally be your own email address of course.
The final hidden field should be the url of the page that should be displayed once the form has been successfully submitted and emailed.
Additional Settings:
All the basic setup was done above but the Auto Form Mailer also provides additional functionality such as setting up required form fields and email validation fields.
To make sure a certain form field is required, prefix it with 'r_' in the name attribute like so:
<input type="text" name="r_Sender_Name" />
To implement the email validation field, where you need to make sure the person entered a valid email address, prefix the field with 'email_' and you're all good to go!
<input type="text" name="email_Sender_Email_Address" />
Download: www.thesocialgeek.com/afm.zip
Live Demo: http://www.thesocialgeek.com/afm/
(try leaving some of the initial fields empty to see the validation results)
More Help:
I have oversimplified this script so it can be used generically. You can alter it slightly to have it working within template systems such as smarty and others. If you need more help with this script, feel free to email me at kamran.usman at gmail dot com and I'll be glad to help.
Enjoy,
Kamran
