Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何重置Google reCaptcha?_Javascript_Php_Recaptcha_Invisible Recaptcha - Fatal编程技术网

Javascript 如何重置Google reCaptcha?

Javascript 如何重置Google reCaptcha?,javascript,php,recaptcha,invisible-recaptcha,Javascript,Php,Recaptcha,Invisible Recaptcha,这是我的PHP代码: function post_captcha($user_response) { $fields_string = ''; $fields = array( 'secret' => '', 'response' => $user_response ); foreach($fields as $key=>$value) $fields_string .= $key . '=' .

这是我的PHP代码:

    function post_captcha($user_response) {
    $fields_string = '';
    $fields = array(
        'secret' => '',
        'response' => $user_response
    );
    foreach($fields as $key=>$value)
    $fields_string .= $key . '=' . $value . '&';
    $fields_string = rtrim($fields_string, '&');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
    $result = curl_exec($ch);
    curl_close($ch);
    return json_decode($result, true);
}
$res = post_captcha($_POST['g-recaptcha-response']);
if (!$res['success']) {
      die('MF005');
} else {
if ($mail->send()) { 
$send_arEmail = $autoresponder->Send();
}}
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script>
function onSubmit(token) {
    document.getElementById("i-recaptcha").submit();
}
</script>
<div class="g-recaptcha" data-sitekey="" ></div>
<button class="button rounded" type="submit" data-callback="onSubmit">Send</button>
这是我的JavaScript代码:

    function post_captcha($user_response) {
    $fields_string = '';
    $fields = array(
        'secret' => '',
        'response' => $user_response
    );
    foreach($fields as $key=>$value)
    $fields_string .= $key . '=' . $value . '&';
    $fields_string = rtrim($fields_string, '&');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
    $result = curl_exec($ch);
    curl_close($ch);
    return json_decode($result, true);
}
$res = post_captcha($_POST['g-recaptcha-response']);
if (!$res['success']) {
      die('MF005');
} else {
if ($mail->send()) { 
$send_arEmail = $autoresponder->Send();
}}
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script>
function onSubmit(token) {
    document.getElementById("i-recaptcha").submit();
}
</script>
<div class="g-recaptcha" data-sitekey="" ></div>
<button class="button rounded" type="submit" data-callback="onSubmit">Send</button>

提交函数(令牌){
document.getElementById(“i-recaptcha”).submit();
}
这是我的验证码:

    function post_captcha($user_response) {
    $fields_string = '';
    $fields = array(
        'secret' => '',
        'response' => $user_response
    );
    foreach($fields as $key=>$value)
    $fields_string .= $key . '=' . $value . '&';
    $fields_string = rtrim($fields_string, '&');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
    $result = curl_exec($ch);
    curl_close($ch);
    return json_decode($result, true);
}
$res = post_captcha($_POST['g-recaptcha-response']);
if (!$res['success']) {
      die('MF005');
} else {
if ($mail->send()) { 
$send_arEmail = $autoresponder->Send();
}}
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script>
function onSubmit(token) {
    document.getElementById("i-recaptcha").submit();
}
</script>
<div class="g-recaptcha" data-sitekey="" ></div>
<button class="button rounded" type="submit" data-callback="onSubmit">Send</button>

这是提交按钮:

    function post_captcha($user_response) {
    $fields_string = '';
    $fields = array(
        'secret' => '',
        'response' => $user_response
    );
    foreach($fields as $key=>$value)
    $fields_string .= $key . '=' . $value . '&';
    $fields_string = rtrim($fields_string, '&');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
    $result = curl_exec($ch);
    curl_close($ch);
    return json_decode($result, true);
}
$res = post_captcha($_POST['g-recaptcha-response']);
if (!$res['success']) {
      die('MF005');
} else {
if ($mail->send()) { 
$send_arEmail = $autoresponder->Send();
}}
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script>
function onSubmit(token) {
    document.getElementById("i-recaptcha").submit();
}
</script>
<div class="g-recaptcha" data-sitekey="" ></div>
<button class="button rounded" type="submit" data-callback="onSubmit">Send</button>
发送
这也是我的表单id:

<form id="i-recaptcha">

**

上述功能正在运行,但在提交表单后,仍会验证码 如果选中,我想在用户单击提交后将其重置为未选中 按钮

**


提前感谢

您可以这样使用它。它是基于版本的

第3版

grecaptcha.ready(function() {
    grecaptcha.execute('SITE_KEY', {action: 'homepage'}).then(function(token){
        $('#token').val(token);
    });
});
第2版

grecaptcha.reset();
第1版

Recaptcha.reload();

我添加了这两个JavaScription,但它不起作用。我如何添加它?你使用的是哪个版本?我不知道哪个版本,你可以看到我上面的代码。请给我一个解决办法。感谢you@Zam85我认为这个grecaptcha.reset();可以为您工作。@Zam85请访问此网站了解有关v2和v3的更多信息。有什么幸运的事情吗?