[英]Google No captcha Recaptcha not working
希望有人能帮忙..我有小工具显示无验证码,并且我在互联网上找到了一个代码,我想使用它,因为我对php不太满意,但它似乎只能部分工作。 每次我单击该框或不尝试发送电子邮件时,都说请检查验证码。
这就是我在邮件的confirm.php文件中所包含的内容,它是服务器端的内容(我认为没有必要按其显示和运行的方式发布小部件代码,这是步骤1)
$email;$message;$sujet;$header;$captcha;
if(isset($_POST['email'])){
$email=$_POST['email'];
}if(isset($_POST['message'])){
$email=$_POST['message'];
}if(isset($_POST['sujet'])){
$email=$_POST['sujet'];
}if(isset($_POST['header'])){
$email=$_POST['header'];
}if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<h2>Please check the the captcha form.</h2>';
exit;
}
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6LcIAgETAAAAAEjbARzUsrkgBIHAeE8QmsNE3US-&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
if($response.success==false)
{
echo '<h2>You are spammer ! Get the @$%K out</h2>';
}
else
{
echo '<h2>Thanks for posting comment.</h2>';
}
根据您的需要修改此代码。
<?
$APIkey = "API KEY";
$postresult=$_POST['g-recaptcha-response'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$APIkey&response=$postresult");
if (strpos($response, 'true')){
//Captcha is valid, do whatever.
} else {
//Captcha is invalid. Tell them to go away.
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.