reCaptcha works correctly and sends my letters from my contact form, but does not redirect to mine thankyou.php. As I said, I get emails, but the default is a blank screen verify.php. I thought it header(location:' ')should work, but it is not. HELP! I am stuck.
<?php
require_once('folder/recaptchalib.php');
$privatekey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
require_once('folder/email.class.php');
if($_POST){
if ($_POST['leaveblank'] != '' or $_POST['dontchange'] != 'http://'){
echo 'Could not deliver your message, please try again!';
exit;
}
$message = '<p><b>Name:</b> '.$_POST['name'].'</p>';
$message .= '<p><b>Email:</b> '.$_POST['email'].'</p>';
$message .= '<p><b>Phone:</b> '.$_POST['phone'].'</p>';
$message .= '<p><b>City:</b> '.$_POST['city'].'</p>';
$message .= '<p><b>State:</b> '.$_POST['state'].'</p>';
$message .= '<p><b>Regarding:</b> '.$_POST['regarding'].'</p>';
$message .= '<p><b>Message:</b> '.$_POST['message'].'</p>';
if($_POST['regarding'] == ''){
$to = 'xxxxx@xxxx.com';
$subject = '';
}elseif($_POST['regarding'] == ''){
$to = 'xxxxx@xxxx.com';
$subject = '';
}elseif($_POST['regarding'] == ''){
$to = 'xxxxx@xxxx.com';
$subject = '';
}elseif($_POST['regarding'] == ''){
$to = 'xxxxx@xxxx.com';
$subject = '';
}else{
$to = 'xxxxx@xxxx.com';
$subject = 'Events: Inquiry';
}
$boundary = uniqid('np');
$headers = "From: xxxxx@xxxx.com" . "\r\n";
$headers .= "Reply-To: xxxxx@xxxx.com" . "\r\n";
$headers .= "Return-Path: xxxxx@xxxx.com" . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Priority: 1\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1;boundary=" . $boundary . "\r\n";
$headers .= "X-MSmail-Priority: High\n";
email(array($to), $subject, $message);
header('Location:thank-you.php');
}
}
?>
source
share