Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

Error validating the Captcha

Started by Muut Archive 9 years ago · 23 replies · 7317 views
9 years ago

Can not send form. Every time I get a "Error validating the Captcha" message after sumitting.

9 years ago

What does your form look like? Did you follow the ReCaptcha example documentation. Also did you set your ReCapatcha information in the form plugin configuration or dynamically in the form itself? Perhaps you can paste or gitst a copy of your page with the form?

9 years ago

Im sure have follow instructions in example documentation.

here you can see the live site with my form. form ist on home page.

hier is the page frontmatter content:

YAML

title: 'Achtsamkeit MBSR - Helga Hummel - Dipl. Psychologin'
process:
    markdown: true
    twig: true
cache_enable: false
recaptchacontact:
    enabled: false
form:
    name: contact
    fields:
        -
            name: name
            label: 'Vor- und Nachname'
            placeholder: 'Geben Sie hier Ihren Namen ein.'
            autofocus: 'off' 
            autocomplete: 'on'
            type: text
            validate:
                required: true
        -
            name: telefonnummer
            label: Telefonnummer
            placeholder: 'Wie kann ich Sie telefonisch erreichen?'
            autocomplete: 'on'
            type: text
            validate:
                required: true
        -
            name: email
            label: E-Mail
            placeholder: 'Geben Sie hier Ihren E-Mail-Adresse ein ein'
            type: email
            validate:
                required: true
        -
            name: message
            label: Nachricht/Frage
            placeholder: 'Ihr Nachricht oder Frage an mich'
            type: textarea
            validate:
                required: false
        -
            name: erstkontakt
            label: Erstkontakt
            placeholder: 'Wie haben Sie von mir erfahren?'
            type: textarea
            validate:
                required: flase
        -
            name: g-recaptcha-response
            label: Captcha
            type: captcha
            recaptcha_site_key: 6Lcf1hQUAAxxxxxxxxxxxxxxznn2ucLoFOt
            recaptcha_not_validated: 'Captcha not valid!'
            validate:
                required: true
    buttons:
        -
            type: submit
            value: Absenden
        -
            type: reset
            value: Reset
    process:
        -
            captcha:
                recaptcha_secret: 6Lcf1hQUAxxxxxxxxxxxxxxxxxxxxxxxxxyXKmUHF
        -
            email:
                subject: '[Site Contact Form] {{ form.value.name|e }}'
                body: '{% include ''forms/data.html.twig'' %}'
        -
            save:
                fileprefix: contact-
                dateformat: Ymd-His-u
                extension: txt
                body: '{% include ''forms/data.txt.twig'' %}'
        -
            message: 'Vielen Dank fuer Ihre Nachricht.'
        -
            display: thankyou
9 years ago

I pasted your recaptcha field and action, added my keys, and the form worked fine for me. Make sure the keys are enabled on the domain you use.

9 years ago

I have already set up many Captcha forms under Joomla. There were never any problems. It is frustrating. The page is ready, only the form with Captcha does not go.

9 years ago

var_dump result after $response = json_decode(file_get_contents($url), true);

{ ["success"]=> bool(false) ["error-codes"]=> array(1) { [0]=> string(22) "missing-input-response" } }

here the recaptcha sourcecode in html output:

<div class="form-data"
data-grav-field="captcha"
data-grav-disabled="true"
data-grav-default="null"

<script>
var captchaOnloadCallback = function captchaOnloadCallback() {
grecaptcha.render('g-recaptcha', {
'sitekey': "6Lcf1hQUAAAxxxxxxxxxxxxxxxxxxxxxxxxxLoFOt",
'callback': captchaValidatedCallback,
'expired-callback': captchaExpiredCallback
});
};
var captchaValidatedCallback = function captchaValidatedCallback() {
};
var captchaExpiredCallback = function captchaExpiredCallback() {
grecaptcha.reset();
};
</script>
<script src="https://www.google.com/recaptcha/api.js?onload=captchaOnloadCallback&render=explicit&hl="
async defer>
</script>
<div class="g-recaptcha" id="g-recaptcha"></div>

9 years ago

dump from $recaptchaSecret and $params["recaptcha_secret"]
string(40) "6Lcf1hQUAAAAAHvwEiCE7rVa4xxHwSl8ayXKmUHF" } int(1)

9 years ago

I have now deleted this recaptcha record for this domain at google-recaptcha tool site and created a new one. The problem also occurs with this new data.

9 years ago

(please post code within triple backticks or triple dashes, it's not readable if not)

The missing-input-response means the response parameter is not sent. What's the dump of $query, in the same funciton? The $query['response'] value should be filled, as I see it defined in the form.

Also try usingname: "g-recaptcha-response" in captcha the form field.

9 years ago

value of $query after submitting is:
secret=6LfB-BQUAAAxxxxxxxxxxxxxxxxxxxxxxxxxj-d0kAg9&response=03AHJ_Vuv aF2yXy3POYccPsHEDFf2ymibItoVqThYpscgv5jMSJCDobT5UeXUGpxhQU3nEuINW9ctswyARrBes7GmwTDrkubCNowLarzhOq_nRQn07HZhK4uVTrnHLx_ZFo2DW2BJgAPm5v7OfKs4D-tAP6YWZf8Kb83kYKcQHd6dzmlIgYlISodKppsGFJGRb_YbdMPri31iZA24IMB5JwZtbVDgmkRuvzbDX8etCnu3obj6pcKLikRPQ_j_qqlnkNXJWWYuNNXSIKhiunsG2r5rWGEzob26NY8cqxN8NGI8vCOYVvbpuPIIHdAnxVlcISmq7tz9fApH4a13VsjC4LfN1nEUcTN290686CviIPoWY5_5HPxtE-IqSWU2cXYkOJ1zNvZpU8nUblwH9ij_NNOzqvffKdJK5HUV2OszH3tRkp8GkYg6bqw6EseUw3AulWMhQrrgYkPGBceR5uM5PzPh-5MpoJaFKEg

9 years ago

Ok so the response parameter is there. Then, I don't understand what the problem is.

9 years ago

Can you show me a sample site where the recaptcha worked fine? this sora sample form has not a captcha.

Is there any step i forgotten?

Yesterday I have installed a virgin grav project in my xampp enviroment using default antimatter template. And I create a new simple form in my-project/contactform. Every time the same error message.

9 years ago

Sorry flavio, but I have visited a lot of pages from this reference list forum:sample-grav-sites. NO captcha is used on any form! Never ever. I'm sure that the GRAV form captcha element does not just work for me! There must be an bug.

9 years ago

This is not a general problem. I have just tried setting up a brand new form on a remote site I have, and it works fine.

Test form:

YAML

title: Contact
published: true
cache_enable: false
cache:
    enabled: false
form:
    name: contact-form
    fields:
        -
            name: email
            label: Email
            id: email
            type: email
            validate:
                required: true
        -
            name: g-recaptcha-response 
            label: Captcha
            type: captcha
            recaptcha_site_key: 6Lxxxxxxxxxxxr8hv
            recaptcha_not_validated: 'Captcha not valid!'
            validate:
                required: true

    buttons:
        -
            type: submit
            value: Submit
    process:
        -
            captcha:
                recaptcha_secret: 6LxxxxxxxxxxxxlI54
        -
            display: thankyou
---
9 years ago

The fact that no site you've seen has a captcha form, does not mean it's because it does not work, that would have been reported before.

Still no clear idea what could be the cause of the problem.

9 years ago

That's true, of course. It just surprised me. But I am helpless and end up with my possibilities.
Should I give you an access? Or pack and send the user directory?
Can I see your remote with captcha site? I would compare the behaviors of both.

9 years ago

Captcha is used on my sample site: http://www.tessa.es and works perfectly. I imagine that you dispose of a private and public key for your site, this is necessary to make captcha work. It's a google (Alphabet) service that you consume. The captcha implementation for forms in GRAV is nothing but an encapsulation for this remote service.

9 years ago

Validation will fail without a proper configuration in the forms plugin. There you will find two settings that allow you to supply the private and public key. You can also specify these keys into the form configuration itself.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1280 9 years ago
Archive · by Muut Archive, 9 years ago
2 888 9 years ago
Archive · by Muut Archive, 9 years ago
2 4017 9 years ago
Archive · by Muut Archive, 9 years ago
1 2892 9 years ago
Archive · by Muut Archive, 9 years ago
3 1077 9 years ago