// COPY RIGHT PHPSCRIPTS4FREE.com 2009, 2010
// Please leave the link below the form intact and PLEASE leave this copyright notice intact
// You may modifiy this script for your own use, but you may not redistribute as your own work
// Questions or the need to break these rules - contact me for permission
// Contact - phpscripts4free.com/howto has a contact form, of course!
// VARIABLES TO CHANGE (Also go to the bottom for the text at the right side of the page)
/* To run this, change the suffix to from txt to php and upload it to your server that can run PHP */
/* VARIABLES TO CHANGE FOR YOUR WEBSITE */
$toemail = 'myemail@mywebsite.com'; /* THE EMAIL ADDRESS YOU WANT THE INFORMATION TO BE SENT TO */
$pagetitle = 'Email Capture Form PHP Demo'; /* The Title and Heading of Your Page */
/* Only Change things below here if you know what you are doing - maybe make a backup of the original */
/* NOTE: At the bottom you can change the text on the RIGHT Side of the Page */
/* START YOUR HTML PAGE WITH HEADERS AND A TITLE */
echo "
";
echo $pagetitle;
echo "\n";
echo "";
Echo $pagetitle;
echo "
";
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
/* Leave this alone - it is how the form will communicate with this program */
$fromemail = $HTTP_POST_VARS['email'];
$subject = $HTTP_POST_VARS['subject'];
$emessage = $HTTP_POST_VARS['emessage'];
$capcha = $HTTP_POST_VARS['capcha'];
$cc = (date("d") * 22 + 6) ; /* Simple Captcha calc */
$message = ""; /* an error or success message */
/* Validation is simple Here */
if ($email == "") {
$message = "All Fields are Required to Send us a Message.";
}
else {
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
$message = "Error This Email Address Looks Invalid";
} elseif ($cc != $capcha) {
$message = "The Captcha Code Must Match";
} elseif ($subject == "") {
$message = "Enter a Subject";
} elseif ($emessage == "") {
$message = "Enter of message";
}
}
if ($message == "") {
// SEND THE MESSAGE HERE
$headers = "From: ".$fromemail . "\r\n";
$sentmessage = "Message sent from .".$ip."\n ".$emessage;
$subject = "EaseFeeds.com Contact ".$subject;
// SIMPLE USE OF MAIL PHP FUNCTION
$mailsent = mail($toemail, $subject, $sentmessage, $headers);
if ($mailsent)
{ $message = "Thanks for Your Email!";
} else {
$message = "Problem with Contact Form" ;
}
}
/* ** End Save RSS Feed Details ** */
/* form Here */
$final_html .= "\n";
$final_html .= "Contact Us Here!\n";
$final_html .= "| ".$message." | ";
$final_html .= "";
$final_html .= " From PHP Scripts for Free"; /* Leave This as courtesy */
$final_html .= " | ";
$final_html .= " | "; /* Close Left Column With Form */
/* Right side of Page - YOu can change this to work for your website if you want*/
$final_html .= "\n";
$final_html .= "It is Simple To Capture Emails and Messages with PHP";
$final_html .= "You can download the demo of this form at";
$final_html .= " How To PHP.";
$final_html .= " This form simply sends an email to the specified TO address embedded in the script. A slightly ";
$final_html .= "more complex form may store the information in a database or in a flat file. We chose to offer the ";
$final_html .= "the beginner script like this so you could just understand the basics without worrying about security, file handling, ";
$final_html .= "or database calls";
$final_html .= "Making the Page Prettier";
$final_html .= "You can change the header or beginning body of the statement to make the html pretty or add your custom headings";
$final_html .= " A slightly more sophisticated versin of the same script is used at ";
$final_html .= " Easy Rss Feeds Contact Form . I did not add this beccause I wanted to keep the coding simple and flexible.";
/* End of Right Side Text */
$final_html .= " |
\n"; /* close right side and table */
echo $final_html;
// CLOSE HTML
echo "";
?>