If you think it will help - here is the entire program. At least you can have a good laugh over it.
It's a very simple contact form, with minimal verification security. In it's present form it works.
The only secure addition is the block that strips out html tag markers.
Code:
<?php
if(isset($_POST['email'])) {
$email_to = "help@debtmasters.ca";
$bcc_to = "debtmaster@debtmasters.ca";
$email_subject = "The On-Line Help contact form";
function died($error) {
echo "We are very sorry, but there were error(s) found in the form you submitted. ";
echo $error."<br />";
echo "Please go back and fix these errors.<br /><br />";
die(); }
if(!isset($_POST['firstname']) ||
!isset($_POST['lastname']) ||
!isset($_POST['email'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.'); }
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email_from = $_POST['email'];
$phone = $_POST['phone'];
$income = $_POST['income'];
$persons = $_POST['persons'];
$debts = $_POST['debts'];
$bankloan = $_POST['bankloan'];
$creditcard = $_POST['creditcard'];
$mortgage = $_POST['mortgage'];
$studentloan = $_POST['studentloan'];
$personalloan = $_POST['personalloan'];
$otherloans = $_POST['otherloans'];
$taxdebt = $_POST['taxdebt'];
$support = $_POST['support'];
$assets = $_POST['assets'];
$gics = $_POST['gics'];
$stocks = $_POST['stocks'];
$auto = $_POST['auto'];
$rrsps = $_POST['rrsps'];
$insurance = $_POST['insurance'];
$property = $_POST['property'];
$otherassets = $_POST['otherassets'];
$comments = $_POST['comments1'];
$verif_box = $_POST['verif_box'];
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= '<br />The Email Address you entered does not appear to be valid.'; }
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$firstname)) {
$error_message .= '<br />The First Name you entered does not appear to be valid.'; }
if(!preg_match($string_exp,$lastname)) {
$error_message .= '<br />The Last Name you entered does not appear to be valid.'; }
if($verif_box <> $_COOKIE['debtmasters']) {
$error_message .= '<br />The Verification Code you entered was not correct.<br />'; }
if(strlen($error_message) > 0) {
died($error_message); }
$email_message = "<html><body>";
$email_message .= "<b>DebtMasters On-Line Help contact form:</b><p>";
$email_message .= "Name: ".$firstname." ".$lastname."<br>";
$email_message .= "Email: ".$email_from."<br>";
$email_message .= "Phone: ".$phone."<p>";
$email_message .= "Income: ".$income."<br>";
$email_message .= "Total Persons: ".$persons."<br>";
$email_message .= "Total Debt: ".$debts."<p>";
$email_message .= "Debts: ". $bankloan." ".$creditcard." ".$mortgage." ".$studentloan." ".$personalloan." ".$otherloans." ".$taxdebt." ".$support."<p>";
$email_message .= "Assets: ". $assets." ".$gics." ".$stocks." ".$auto." ".$rrsps." ".$insurance." ".$property." ".$otherassets."<p>";
$email_message .= "Comments: <br>";
$comm2 = str_replace("<","[",$comments);
$comm3 = str_replace(">","]",$comm2);
$comm4 = stripslashes($comm3);
$hlr = chr(13);
$comments = str_replace($hlr,"<br>",$comm4);
$email_message .= $comments."<p>";
$email_message .= " </html>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html" . "\r\n";
$headers .= 'bcc: '.$bcc_to."\r\n" .
$headers .= 'From: ' . $email_from . "\r\n";
@mail($email_to,$email_subject,$email_message,$headers);
include "1Fonlinepost.php" ;
setcookie('debtmasters','');
}
?>
It sends - but the requirement for the "@" still bugs me - along with the 160+ trials it took to get it working.
Bookmarks