添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

We have a live reCaptcha v2 implementation at the following URL:

https://och.stonybrook.edu/index.php?page=roommates&task=submit

The reCaptcha has been working fine until reported to me as not working today.

I have identified the following:

  • The reCaptcha JS is loading successfully
  • The reCaptcha is working well on the form -- creating the element, checking the box and adding an encrypted string to the g-recaptcha-response textarea element that is created by the library.
  • However, on the server I am seeing no value for $_POST['g-recaptcha-response']
  • When I var_dump the $_POST array in PHP, I see all other form values but not this one. It does not exist as an index in the $_POST array
  • I have:

  • Verified domain in reCAPTCHA admin
  • Created a new site/secret key pair
  • Tried the test key pair provided by Google via the docs
  • I can't get to the bottom of why that <textarea> is not posting its data to the server.

    I have crawled the docs at https://developers.google.com/recaptcha/docs/verify to no avail.

    HTML:

    <!-- Using the Auto Render implementation as described in 
    https://developers.google.com/recaptcha/docs/display#auto_render -->
    <!-- in <head> -->
    <script src="https://www.google.com/recaptcha/api.js"></script>
    <!-- in <form> -->
    <div class="g-recaptcha" data-sitekey="SITE_KEY"></div>
    
    echo($_POST['g-recaptcha-response']); //outputs nothing
    var_dump($_POST); //outputs all of my form values, except for <textarea id="g-recaptcha-response">
                    we also can't see the page at that URL in the link, gets redirect to a login page instead
    – ADyson
                    Jan 22, 2018 at 20:02
                    I am implementing reCaptcha v2 on a very old site (not created by me). In my case the html was indeed malformed. Thanks.
    – marlar
                    Jan 13, 2021 at 12:18
            

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.