include("classy/class.classy.php");
$page = new classy_page(); //create instance of classy page
/*
//$page->track();
*/
include("config.php");
#### contact form sutff ###################################################
if(isset($_POST['submit'])) {
$firstname = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['firstname']);
$lastname = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['lastname']);
$email = preg_replace("/[^a-zA-Z0-9 -@.]/", "", strtolower($_POST['email']));
$confirmemail = preg_replace("/[^a-zA-Z0-9 -@.]/", "", strtolower($_POST['confirmemail']));
if($email != $confirmemail){
$emailerror = "nomatch";
$email = "";
$confirmemail = "";
$emaildisplayerror = "
The emails you entered did not match.
";
} else {
$regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
// Presume that the email is invalid
$valid = 0;
$valid = eregi($regexp, $email);
if($valid == 0){
$emailerror = "invalid";
$email = "";
$confirmemail = "";
$emaildisplayerror = "
The email address you entered is invalid.
";
}
}
$company = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['company']);
$title = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['title']);
$phone = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['phone']);
$address1 = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['address1']);
$address2 = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['address2']);
$city = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['city']);
$state = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['state']);
$postal = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['postal']);
$ordernumber = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['ordernumber']);
$purchasedate = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['purchasedate']);
$inquirytype = preg_replace("/[^a-zA-Z0-9 -\/]/", "", $_POST['inquirytype']);
$subject = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['subject']);
$other = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['other']);
$comments = addslashes(strip_tags($_POST['comments']));
$ip = $_SERVER['REMOTE_ADDR'];
$captcha = preg_replace("/[^a-zA-Z0-9 -]/", "", $_POST['captcha']);
if($firstname == ""){
$firstnameerror = "
Required Field.";
}
if($lastname == ""){
$lastnameerror = "
Required Field.";
}
if($inquirytype == ""){
$inquirytypeerror = "
Required Field.";
}
if($subject == ""){
$subjecterror = "
Required Field.";
}
if($captcha != $_SESSION['enc_img']){
$captchaerror = "
Please Try Again.";
} else {
$_SESSION['cP'] = "true";
}
$ballast = "company=$company%title=$title%ordernumber=$ordernumber%purchasedate=$purchasedate%inquirytype=$inquirytype%subject=$subject%other=$other%comments=$comments";
if(!$emailerror && !$firstnameerror && !$lastnameerror && !$inquirytypeerror && !$subjecterror && $_SESSION['cP'] == "true"){
$mysqli = $page->db_connect();
$sql = "insert into elist set fname='$firstname', lname='$lastname', email='$email', phone='$phone', add1='$address1', add2='$address2', city='$city', state='$state', zip='$postal', ballast='$ballast', ip='$ip', sid='$sid', type='GCOC', test='$ab', referer='$referer'";
$result = $mysqli->query($sql);
$displayblock = "Thank you for your submission.
If you are a consumer and would like to place an order, or talk to someone about an order you have already placed,
please call us at 1-800-888-7594 Monday through Friday, from 8:00am to 4:30pm Pacific Time.
Thanks Again, Gourmet Cooking Online Team
";
//email josh
$to = "contact@mdgco.com";
$subject = "GCO Contact Inquiry";
$message = "$sql";
$message = str_replace("insert into elist set ", "", $message);
$message = str_replace(",", "\n", $message);
$message = str_replace("ballast='","",$message);
$message = str_replace("="," = ",$message);
$message = str_replace("%", "\n", $message);
$message = wordwrap($message, 70); //wraps text cause a line can't be longer than 70 characters
mail("$to","$subject","$message");
}
}
$stateArray=array("","AL","AK","AZ","AR","AS","CA","CO","CT","DE","DC","FM","FL","GA","GU","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MH","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","MP","OH","OK","OR","PA","PR","RI","SC","SD","TN","TX","UT","VT","VA","VI","WA","WV","WI","WY","AA","AE","AP","- -","AB","BC","MB","NB","NL","NT","NS","ON","PE","QC","SK","YT");
$state_drop = createDrop("state", $stateArray, $state);
$inquiryArray=array("","US Consumer","Media / Public Relations","US Retail / Wholesale","International","Affiliate / Marketing","Instructor / Pro","Vendors / Purchasing","Inventor");
$inquiry_drop = createDrop("inquirytype", $inquiryArray, $inquirytype);
$subjectArray=array("","Delivery Status","General product inquiry","Would like to place a phone order","Report a product problem","Report a billing problem","Report a shipping problem","Testimonial","Comments","International consumer","Other");
$subject_drop = createDrop("subject", $subjectArray, $subject);
//Create Captcha image
// generate random encryption string
$enc_str = rand(1,1000);
$_SESSION['enc_img'] = substr(md5('allbadcatsgotokittyhell'.$enc_str), 2,6);
// build captcha bloack
if ($_SESSION['cP'] == "true") {
$captcha_block = "Thank You for Providing Verification.";
$captchaerror = "";
} else {
$captcha_block = "
";
}
?>