session_start(); include_once($_SERVER['DOCUMENT_ROOT']."/includes/config.php"); //include_once($_SERVER['DOCUMENT_ROOT']."/includes/db_connect.php"); // establish database connection include_once($_SERVER['DOCUMENT_ROOT']."/includes/inc_functions.php"); // load functions $thisSection = "Contact Us"; $thisSub = ""; $thisPage = ""; if ($_POST['submitChecker'] == 1) { // Form Information $firstName = trim($_POST['firstName']); $lastName = trim($_POST['lastName']); $organization = trim($_POST['organization']); $title = trim($_POST['title']); $emailAddress = trim($_POST['emailAddress']); $phone = trim($_POST['phone']); $website = trim($_POST['website']); $address = trim($_POST['address']); $address2 = trim($_POST['address2']); $city = trim($_POST['city']); $state = trim($_POST['state']); $zipcode = trim($_POST['zipcode']); $country = trim($_POST['country']); $comments = trim($_POST['comments']); $subscribe = trim($_POST['subscribe']); $code = strip_tags(trim($_POST['code'])); $thisTime = time(); $dateAdded = date("Y-m-j H:i:s", $thisTime); // Begin checking information if (strlen($firstName) == 0) { $error[] = "The first name is required."; } if (strlen($lastName) == 0) { $error[] = "The last name is required."; } if ((!preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $emailAddress)) || (strlen($emailAddress) == 0)) { $error[] = "The email address you entered is not valid."; } if (strlen($comments) == 0) { $error[] = "Your comment or question is required."; } if (strtolower($_REQUEST['code']) != $_SESSION['code']) { $error[] = "The four letters you entered were incorrect."; } if (strlen($subscribe) == 0) { $subscribe = "No"; } if (count($error) == 0) { // If there are no errors in the form input... //$to = "hugo@bridgehouse.net"; $to = "hugo@bridgehouse.net"; // $from = $emailAddress; $from = "bhform@bridgehouse.net"; $subject = "BH Contact Form ($firstName $lastName)"; $message = "The following e-mail was submitted on $dateAdded First Name: $firstName Last Name: $lastName Title: $title Organization: $organization Phone: $phone E-Mail: $emailAddress Mailing Address: $address Comments/Questions: $comments\n End of e-mail"; $headers = "From: $from\r\n"; // $headers .= "Reply-To: $emailAddress\r\n"; $success = mail($to, $subject, $message, $headers); $sendOk = 1; // add contact $query_contactAdd = "INSERT INTO Contacts SET firstName = '$firstName', lastName = '$lastName', organization = '$organization', title = '$title', address = '$address', address2 = '$address2', city = '$city', state = '$state', zipcode = '$zipcode', country = '$country', phone = '$phone', emailAddress = '$emailAddress', website ='$website', comments = '$comments', subscribe = '$subscribe', dateAdded = '$dateAdded'"; $result_contactAdd = mysql_query($query_contactAdd) or die ("Contact Addition Failed with Error: " .mysql_error()); $sendOk = 1; } } // end Submitchecker ?>