K
K
KoRNeT46RuS2017-04-19 13:10:04
Google
KoRNeT46RuS, 2017-04-19 13:10:04

Why does google recaptcha kill POST by returning it empty?

Put 2 Invisible Recaptchas. 1 works flawlessly. 2nd works, but the post from the form comes empty. I can't figure out what's wrong
First form

<form id="contactForm1" action="/feed.php" method="post">
        <input type="text" name="call_name" placeholder="Ваше имя">
        <input type="text" name="call_num" placeholder="Номер телефона">
                                        id="submit1"
                                        type="submit"
                                        value="Заказать"
                                >
       </form>

Second form
<form action="/feed.php" id="contactForm2" method="post">
          <input type="text" name="call_name" placeholder="ФИО">
          <input type="text" name="call_num" placeholder="E-mail или телефон">
          <textarea name="call_comment" rows="4" cols="40" placeholder="Ваше сообщение"></textarea>
         <input id="submit2" type="submit" value="Заказать">
        </form>

Google calls below
<script type="text/javascript">
            var onSubmit1 = function(token) {
                document.getElementById('contactForm1').submit();
            };
            var onSubmit2 = function(token) {
                document.getElementById('contactForm2').submit();
            };
            var onloadCallback = function() {
                grecaptcha.render('submit1', {
                    'sitekey' : 'ключ1',
                    'callback' : onSubmit1
                });
                grecaptcha.render('submit2', {
                    'sitekey' : 'ключ2',
                    'callback' : onSubmit2
                });
            };
        </script>
        <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" type="text/javascript"></script>

The post comes from the second form empty
array(3) { ["call_name"]=> string(0) "" ["call_num"]=> string(0) "" ["call_comment"]=> string(0) "" }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lehha, 2017-04-29
@lehha

Pay attention to the html-code of your form, if it is not shown here in full. For example, if the tag is inserted before . It sounds unbelievable, but it's a fact.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question