How can I access multiple individual reCAPTCHA responses from the same page?

不羁岁月 提交于 2019-12-10 21:53:41

问题


I have multiple reCAPTCHAS on the same page, and all reCAPTCHAS return $_POST['g-recaptcha-response'] by default. Is there a way so that I can change the $_POST name for each Recaptcha, and therefore access the individual responses of them?

If my site keys / secret keys are the same, will this mean that I can't access the individual responses?

Thanks for the help! :)

HTML:

<div class="g-recaptcha" id="recaptcha1"></div>
<div class="g-recaptcha" id="recaptcha2"></div>

jQuery:

var recaptcha1 = $("#recaptcha1");
var recaptcha2 = $("#recaptcha2");
var myCallBack = function() {
    //Render the recaptcha1 on the element with ID "recaptcha1"
    recaptcha1 = grecaptcha.render('recaptcha1', {
    'sitekey' : 'removed_for_demonstration',
      'theme' : 'light'
    });

    //Render the recaptcha2 on the element with ID "recaptcha2"
    recaptcha2 = grecaptcha.render('recaptcha2', {
      'sitekey' : 'removed_for_demonstration',
      'theme' : 'light'
    });
};

PHP:

$captcha = isset($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : "";

来源:https://stackoverflow.com/questions/29315369/how-can-i-access-multiple-individual-recaptcha-responses-from-the-same-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!