Recaptcha用户验证的错误查询

时间:2018-11-21 22:13:33

标签: php jquery html json recaptcha

我正在尝试插入验证码和按钮,但是要进入并继续下一页而不进行验证 这是我的html:

    <form method="POST">
<div class="g-recaptcha" data-sitekey="my site key"></div>
<button name="submit"></button>
</form>

这是我在php中的尝试:

<?php 

if (isset($_POST['submit'])) {
$url='https://www.google.com/recaptcha/api/siteverify';
$privatekey='my key';
$response=file_get_contents($url.'?secret='.$privatekey.'&response='.$_POST['g-recaptcha-response'].'&remote'.$_SERVER['REMOTE_ADDR']);
$data=json_decode($response);
if (isset($data->success) AND $data==true) {
echo 'location:files/index.php';
}
}
 ?>

0 个答案:

没有答案