Google Recaptcha运行良好,但有时它不会显示图像。它会自动获得一个勾号,而无需验证。它不会发送表单详细信息。有人能帮我吗?点击下面的链接进行检查。
访问我的网站链接
它主要不适用于手机。
我使用了Github的Recaptchaphp库Github Recaptcha
我使用了以下代码
<form class="form-horizontal" id="ajax-contact-form1" action="" method="post" autocomplete="on" onsubmit="return myFunction()">
<?php
require_once "recaptchalib.php";
// your secret key
$secret = "xxxxxx";
// empty response
$response = null;
// check secret key
$reCaptcha = new ReCaptcha($secret);
// if submitted check response
if ($_POST["g-recaptcha-response"]) {
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}
if ($response != null && $response->success) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "xxxx@gmail.com";
$email_to2 = "xxxx@gmail.com";
$email_to3 = "xxxx@outlook.com";
$email_subject = "Play Of Paints Response";
$success = false;
$first_name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['phone']; // not required
$comments = $_POST['message']; // required
$error_message = "";
$email_message = "Devour...'n'n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($first_name)."'n";
$email_message .= "Email: ".clean_string($email_from)."'n";
$email_message .= "Telephone: ".clean_string($telephone)."'n";
$email_message .= "Message: ".clean_string($comments)."'n";
// create email headers
$headers = 'From: Play Of Paints<www.playofpaints.com>'.$email_to3."'r'n".
'Reply-To: '.$email_to3."'r'n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to2, $email_subject, $email_message, $headers);
$success = mail($email_to, $email_subject, $email_message, $headers);
echo nl2br("Hello " . $_POST["name"] . " (" . $_POST["email"] . "), thanks for submitting the form! 'n'n<strong>You will be contacted shortly!</strong>");
} else { echo "Please enter your details below";
}
?>
<div class="control-group">
<br>
<label class="control-label" for="inputName">Your full name:</label>
<div class="controls">
<input class="" type="text" id="contact_name" name="name" placeholder="Your full name:" >
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">Your email:</label>
<div class="controls">
<input class="" type="email" id="inputEmail" name="email" placeholder="Your email:" onBlur="if(this.value=='') this.value='Your email:'" onFocus="if(this.value =='Your email:' ) this.value=''" >
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPhone">Phone number:</label>
<div class="controls">
<input class="contact_phone" type="tel" id="inputPhone" name="phone" placeholder="Phone number:" onBlur="if(this.value=='') this.value='Phone number:'" onFocus="if(this.value =='Phone number:' ) this.value=''" >
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPhone">City</label>
<div class="controls">
<input type="text" name="firstname" value="Bangalore" readonly>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputMessage">Message:</label>
<div class="controls">
<textarea class="" id="contact_message" name="message" placeholder="Message:" ></textarea>
</div>
</div>
<div class="g-recaptcha" data-sitekey="6LfaGhETAAAAAMtEMP_dYoU-AbgaHLedpMWGiQ-7"></div>
<br>
<button type="submit" class="submit">submit</button>
</form>
https://support.google.com/recaptcha/?hl=en
转到"使用reCAPTCHA V2 "部分
如何使用reCAPTCHA
有时我们需要你提供一些额外的信息,以确保你是人类而不是机器人,所以我们要求你解决的挑战
只有有时而不是总是