小编nik*_*sla的帖子

无法获得google recaptcha v2以防止表单提交

因此,我可以使用以下代码成功获取验证码.

  </p>
<?php
if(isset($_POST['g-recaptcha-response'])){
echo verify($_POST['g-recaptcha-response']);

}

function verify($response) {
$ip = $_SERVER['blank']; //server Ip
$key="secretkey"; // Secret key

//Build up the url
$url = 'https://www.google.com/recaptcha/api/siteverify';
$full_url = $url.'?secret='.$key.'&response='.$response.'&remoteip='.$ip;

//Get the response back decode the json
$data = json_decode(file_get_contents($full_url));
//Return true or false, based on users input
if(isset($data->success) && $data->success == true) {
return True;
}
return False;
}
?>
<p style="text-align: justify;">
Run Code Online (Sandbox Code Playgroud)
<script type="text/javascript">
 function verify(){
 var serializedValues = jQuery("#infoForm").serialize();
 jQuery.ajax({ type: 'POST',url:"verify.php",data: serializedValues,success:function(result){
 if(result){
 $('#show').html('Your Form Successfully Submitted'); …
Run Code Online (Sandbox Code Playgroud)

html php jquery captcha

2
推荐指数
2
解决办法
5412
查看次数

标签 统计

captcha ×1

html ×1

jquery ×1

php ×1