Hello,
I'm working on adding a captcha for our contact form. The link to the test version of the form can me seen here: http://www.coastalpet.com/test/index.php. (On submit, the information from this form is emailed to me, so if you want to test it, no problem... I'm the only person who will see it.) Everything works fine, but the thank you and fail pages go to a solid white page with the text, rather than the text on a page that matches the rest of the site (i.e. header, menu, footer, etc.) as the current contact page does. I've been rearranging things on the process page with no luck. The code for this form is the same code as the current contact form, just with the addition of the captcha chunk. I'm sure it's something simple, but I am baffled! Thank you in advance!
Here is the code for the process/verify page (with the captcha):
<?php
//Collect contact form data
//Check Special Field
//Email ASC & Webmaster
//Email Sender
//Redirect to thank you page
require_once($_SERVER['DOCUMENT_ROOT'].'/functions.php');
/******** CONTACT DATA **********/
$name = stripslashes($_POST['name']);
$company = stripslashes($_POST['company']);
$address = stripslashes($_POST['address']);
$city = stripslashes($_POST['city']);
$state = stripslashes($_POST['state']);
$zipcode = stripslashes($_POST['zipcode']);
$country = stripslashes($_POST['country']);
$website = $_POST['website'];
$phone = stripslashes($_POST['phone']);
$fax = stripslashes($_POST['fax']);
$email = stripslashes($_POST['contact']);
$Referred = stripslashes($_POST['referred']);
$CustomerType = stripslashes($_POST['CustomerType']);
$Comments = stripslashes($_POST['comments']);
/******** CHECK SPECIAL FIELD **********/
$spamcheck = stripslashes($_POST['email']);
//if spamcheck isnt blank exit page, no need for error message to user, as its a spam bot
if ($spamcheck!=="") {
exit;
}
/******CAPTCHA******/
require_once('adscaptchalib.php');
$captchaId = '5984'; // Set your captcha id here
$privateKey = 'removed'; // Set your private key here
$challengeValue = $_POST['adscaptcha_challenge_field'];
$responseValue = $_POST['adscaptcha_response_field'];
$remoteAddress = $_SERVER["REMOTE_ADDR"];
if ("true" == ValidateCaptcha($captchaId, $privateKey, $challengeValue, $responseValue, $remoteAddress))
{
// Correct answer, continue with your submission process
$success = mail($email_address, $subject, $message, $headers);
} else {
// Wrong answer, you may display a new AdsCaptcha and add an error message
die ("The CAPTCHA wasn't entered correctly. Please go back and try it again.");
}
/******** EMAIL ASC & WEBMASTER **********/
$message = "
-----------------------------------------------------------------------------
Information Inquiry
-----------------------------------------------------------------------------
$name has visited the Coastal web site and would like some information.
The details they entered on the website are:
Name: $name
Company: $company
Address: $address
City: $city
State: $state
Zip Code: $zipcode
Country: $country
Website: $website
Phone: $phone
Fax: $fax
Email: $email
Referred to web site: $Referred
CustomerType: $CustomerType
Comments: $Comments
Kind Regards,
Coastal Pet Products, Inc.
http://www.coastalpet.com
";
$email_address = "example@example.com";
$subject = "Information Inquiry";
$headers = "From: $name <$email>";
$message = str_replace("\r",'',$message); //fixes postfix php bug that double spaces messages
/******** EMAIL SENDER **********/
$message2 = "
-----------------------------------------------------------------------------
Re: Information Inquiry
-----------------------------------------------------------------------------
Thank you $name for visiting the Coastal Pet Products web site. We will be using the details you entered to contact you.
Name: $name
Company: $company
Address: $address
City: $city
State: $state
Zip Code: $zipcode
Country: $country
Website: $website
Phone: $phone
Fax: $fax
Email: $email
Referred to web site: $Referred
CustomerType: $CustomerType
Comments: $Comments
Kind Regards,
Coastal Pet Products, Inc
http://www.coastalpet.com
";
$email_address2 = "$email";
$subject2 = "Re: Information Inquiry";
$headers2 = "From: Coastal Pet Products <example@example.com>";
$message2 = str_replace("\r",'',$message2); //fixes postfix php bug that double spaces messages
//send message 1 and save result in success var (either true for success, or false for fail)
$success = mail($email_address, $subject, $message, $headers);
//conditionally send message2, no need to check success on this one
if (strpos($email,'@aol.com') == false) {
mail($email_address2, $subject2, $message2, $headers2);
}
if ($success):?>
<h3>Thank you for your interest in Coastal Pet Products!</h3>
<p>If you have asked us to contact you, we will be using the information you provided. We thank you for taking the time to help us be a better company.</p>
<?php else:?>
<p>There was a problem submitting your information. Please try again.</p>
<p>If you continue to have problems, please contact Customer Service at 1-800-321-0248.</p>
<?php endif;?>