Free PHP Mail Form
If you’re too lazy to follow my tutorial on creating an advanced php form you can download one for free: mail_form.txt.
Features
Stuff that comes as standard:
- Meta header and JavaScript injection protection
- Tags stripped and whitespace trimmed
- Validity and length checking on name and e-mail fields
- IP and browser details included in e-mail
- Valid data displayed when other errors occur
- Spam word check (new!)
- Common spam bot blocking (new!)
Install Instructions
Follow these for best results:
- Save the contents of mail_form.txt to a file called form.php
- Change each occurrence of YOUR-EMAIL@MAIL.COM to your personal e-mail address and each occurrence of YOUR WEBSITE to your website name or address.
- Add your styling and make it pretty — customise the title of the page too.
Adding Fields
To add fields to the form, simply edit the form HTML near the bottom of the file. To ensure that submitted data is placed back in the form if an error occurs, be sure to use the get_data() function with the name of the field placed inside. E.g. to add a nickname field, you would add:
<label><input type="text" name="nickname" id="nickname" value="<?php get_data("nickname"); ?>" /> Nickname</label><br />
Notice how the name and id attribute values are the same as the value between the quotation marks inside the get_data() function? Note: get_data() does not work with radio buttons, checkboxes and drop-down menus.
Grab the free mail form script?
Disclaimer
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Page created: April 7, 2008
Page last modified: August 12, 2008

![[feed]](/images/feed.gif)
