Secure PHP Mail Form
Free PHP Mail Form is a single-page multi-use PHP mail (e-mail) website form that allows your users to send you feedback directly from your website, without the need to customise heavily detailed scripts and panic over security.
Download Options
Download the mail form to your computer, and re-name it to suit your website (e.g. to contact.php). Please note: you must find the form action code in the script (e.g. <form action="mail_form_v2.php" method="post">) and set the action attribute to whatever you decide to name the form file.
- Download version 1: light spam protection
- Download version 2: advanced spam protection (recommended)
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
- Common spam bot blocking
- New in v2: Bayesian style spam filtering
Install Instructions
Follow these for best results:
Version 1
- 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.
Version 2
- Save the contents of mail_form_v2.txt to your computer, and rename to suit
- Customise the variables at the top of the script ($yourEmail = “YOU@YOURWEBSITE.COM”; etc)
- 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 for="nickname">Nickname<label><input type="text" name="nickname" id="nickname" value="<?php get_data("nickname"); ?>" /><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.
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.
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.


