好的,我的联系表格 (http://jshjohnson.com/new/contact.php) 可以正常工作,但是 ReCaptcha 错误(通常在您输入错误的单词时出现)显示在页面加载中。
我已经设置了一个名为 message 的空变量,它应该会阻止它,但不幸的是它没有。
<?php
include("functions.php");
require_once('recaptchalib.php');
$publickey = "6LdLX9oSAAAAALZawj-uldWrjsI0zYcR-w_r_sNh";
$privatekey = "<removed>";
$resp = recaptcha_check_answer($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
$recaptcha_form = recaptcha_get_html($publickey);
$message = "";
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
$message = "The reCAPTCHA wasn't entered correctly. Go back and try it again.
(reCAPTCHA said: " . $resp->error . ")";
} else {
// ADD YOUR CODE HERE to handle a successful ReCAPTCHA submission
// e.g. Validate the data
$myemail = "contact@jshjohnson.com";
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
$fullname = $firstname . " " . $surname;
$email = $_POST['email'];
$contact = $_POST['message'];
$website = $_POST['website'];
$subject = "Website Contact";
if($firstname == '') {
$message = 'Please type your first name' ;
} else if ($surname == '') {
$message = 'Please type your surname';
} else if ($email == '') {
$message = 'Please type your email';
if (preg_match("/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/", $email)) {
$message = "Email address is valid";
} else {
$message = "Email address is invalid";
}
} else if ($contact == '') {
$message = 'Please type your message';
} else {
/* Let's prepare the message for the e-mail */
$contact = "Hello!
Josh Johnson Web Design contact form has been submitted by:
Name:* $fullname
E-mail:* $email
Website: $website
Budget: £
Message:*
$contact
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $contact);
/* Redirect visitor to the thank you page */
header('Location: index.php');
exit();
}
}
?>
有任何想法吗??