NOTE: submit button should be named "submit" or "Submit"; value can be anything
NOTE: Email form tag should be named "email" or "Email"; value will be entered by submitter
*/
/*PSEUDO CAPTCHA: enter the answer to your "pseudo-captcha" question; if you are NOT using the
pseudo-captcha option, leave the defined field empty.
NOTE: the form field name must be "pseudo-captcha".
Example:
Is water wet or dry?
*/
define("PSEUDO_CAPTCHA_RESPONSE", "wet");
/*SPAM PREVENTION: enter 1 if you want to prevent users from entering 'http://' in any form field
NOTE: The person submitting cannot put "http://" in any form field, even for a website's URL;
prefix that form field with the http:// for them, and put a note on your form page that if
they put http:// in any form field, their form will be rejected as spam; I usually put this
next to the "required fields" notice, or immediately above the form field
Example:
Your website: (do not enter "http://" or your form will be rejected as spam)
http://
*/
define("PREVENT_HTTP", "1");
/*REQUIRED FIELDS: enter required fields (no spaces in field names!), delimited by a comma,
or leave blank for none; if you are requiring a field that you want as two or
more words in the email, use the underscore "_" to separate the words on your form.
Example: "Your Name" as text is "Name_of_person_submitting_form" as the form field.
It will show up in the email as "Name of person submitting form:".
NOTE: do not use cache-control header tags on the contact form file, or the person submitting
might not be able to get back to their form with their existing values intact. This
is not the most graceful way to check for required fields, but this approach will work
with an html contact file and does not require javascript (which can be bypassed VERY
easily in Opera browsers).
UPDATE: Another thing to note is that this script works best with .htm or .html contact files.
For some reason that I haven't figured out yet, PHP will remove the entered values,
even though I am not including cache-control header tags.
*/
define("REQUIRED_FIELDS_COMMA_DELIMITED", "Name_of_person_submitting_form,Email,Country");
//enter 1 if you prefer html email; enter 0 if you prefer text email
define("HTML_EMAIL", "1");
//enter 1 if you are using a reset button on your form; enter 0 if you are not
define("USING_RESET_BUTTON", "0");
//put the "from" email address here; many servers require that this domain be the website domain
define("FROM", "info@website.com");
//put the receipient(s) email address here; separate multiple emails with a comma
define("SEND_TO_EMAIL", "info@website.com");
//enter 1 if person submitting should receive copy; enter 0 if not
define("CC_EMAIL", "1");
//put the website name here
define("WEBSITE", "Website");
//change subject line to your preference
define("SUBJECT_LINE", "Sample Contact Form Submission");
//enter the FULL name of the file that you want to return visitors to after they submit
define("REDIRECT_PAGE_NAME", "http://www.website.com/thankyou.htm");
/* IF YOU ARE HAVING PROBLEMS EMAILING,
uncomment the ini_set lines and specify your SMTP Server, Port and Valid From Address
*/
//ini_set("smtp","mail.website.com");
//ini_set("smtp_port","25");
//ini_set("sendmail_from","from@website.com");
/*
Problems? Questions? Suggestions?
Contact me at jenny - at - whitewavedesigns.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DO NOT CHANGE ANYTHING BELOW THIS LINE */
//check pseudo-captcha
if (PSEUDO_CAPTCHA_RESPONSE && PSEUDO_CAPTCHA_RESPONSE <> $_POST['pseudo-captcha'])
{
echo 'Your pseudo-captcha response '.$_POST['pseudo-captcha'].' is invalid! Please use your browser\'s back button, correct and submit again.
';
exit;
}
//check required fields:
$requiredAR = explode(",", REQUIRED_FIELDS_COMMA_DELIMITED);
if ($requiredAR[0]) //make sure there is really a required field
{
foreach ($requiredAR as $required)
{
if (!$_POST[trim($required)]) $requiredMsg = $requiredMsg.$required.' is a required field! Please use your browser\'s back button, complete the form, and submit again.
';
if (strtolower($required) == 'email') //validate email
{
$email = $_POST['Email'];
if (!$email) $email = $_POST['email'];
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $requiredMsg = $requiredMsg.$required.' is invalid! Please use your browser\'s back button, correct and submit again.
';
}
}
}
if ($requiredMsg)
{
echo $requiredMsg;
exit;
}
if ($_POST['Email']) define("CC_EMAIL_ADDRESS", $_POST['Email']);
else define("CC_EMAIL_ADDRESS", $_POST['email']);
if (noHeaders(CC_EMAIL_ADDRESS))
{
emailPostForm($_POST);
header("Location:".REDIRECT_PAGE_NAME);
}
else //spam attempt; redirect somewhere else
{
header("Location:http://www.google.com/");
}
function emailPostForm($postformAR)
{
$headers = '';
if (HTML_EMAIL)
{
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
}
$headers.= 'From: '.WEBSITE.' Website <'.FROM.'>';
if (CC_EMAIL) $headers.= "\r\nCC:".CC_EMAIL_ADDRESS."";
$space = '';
$trtd_open = '