IT.COM

Experience with binding reCaptcha to formmail.php Contact Us form

NameSilo
Watch

xynames

XYNames.comTop Member
Impact
12,001
I've got the reCaptcha code on the page
<script src="https://www.google.com/recaptcha/api.js"></script>
between <head> and </head>

also the
<div class="g-recaptcha"
data-sitekey="SITEKEY HERE">
</div>

above the
<input type="submit" value="Send Now" class="btn3">

and the reCaptcha appears and works, but when I try to implement the binding code into the formmail.php I get errors on submit.

With no binding code in the formmail.php the reCaptcha appears and works but whether passed or ignored the formmail.php still allows the submission to pass.

So, not sure what code to put into the formmail.php side to handle the integration.

Basically using this formmail
https://www.tectite.com/formmailpage.php
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
what is the url of your site?
 
0
•••
I have a test site up where I am testing the reCaptcha

xybrand dot com

The reCaptcha is there but whether you pass it or not, still the contact us form lets you submit.

What I am missing is the code to stick into the formmail.php to force the verification of the reCaptcha response.
 
Last edited:
0
•••
0
•••
0
•••
I'll experiment with toggling it. I'm not so much getting "attacked" as a few SPAMs a day with the usual stupid URLs in the contact us form directing to some porn site.
 
0
•••
Great. I think that setting is why the forms are not processing. Also, you might want to move the form code out of the <li> that contains your submit button and text area. It should have it's own <li></li>
 
0
•••
Okay I'll work on it, will advise!

I thought that the reCaptcha had to have some kind of code added within the formmail.php to invoke it, or bind it. But whatever code I found online and added into the formmail.php created errors such that the Contact Us form stopped working entirely.

At this moment, the Contact Us form works fine, no errors - but whether you pass the reCaptcha or not, still it lets you submit.
 
Last edited:
0
•••
Your form isn't checking "g-recaptcha-response".
 
0
•••
Thanks. Yes but do I need to add some code within the xybrand page or within the formmail.php , to make it check the recaptcha.
 
Last edited:
0
•••
Thanks. Yes but do I need to add some code within the xybrand page or within the formmail.php

I'll try to figure it out in a few hours.
 
0
•••
Thanks. Yes but do I need to add some code within the xybrand page or within the formmail.php , to make it check the recaptcha.

Fixed it,
Check line 618, make sure the value is not blank.
/* Help: http://www.tectite.com/fmdoc/require_captcha.php */
$REQUIRE_CAPTCHA = "Please complete the captcha challenge ";

My advice, find a new form builder. Formmailer.php is 15K lines of obsolete and unneeded code.
 
Last edited:
0
•••
@xynames - Gave it second try and found var at line 618 need a value. Wasn't listed in the instructions.
 
0
•••
Thanks again.

I changed line 618 to be
/* Help: http://www.tectite.com/fmdoc/require_captcha.php */
$REQUIRE_CAPTCHA = "Please complete the captcha challenge"; /* set to a message string if your forms */
// must provide a CAPTCHA string

and also I added the recaptcha site key to line
/* Help: http://www.tectite.com/fmdoc/recaptcha_private_key.php */
$RECAPTCHA_PRIVATE_KEY = "____________________";

but now, whether I complete the recaptcha or not, still I get the message that "Please complete the captcha challenge"

I tried inputting both the secret key and site key didn't make any difference.

Within my Google console, there is a record of passes and fails on the reCaptcha from yesterday, so something is happening between the key and Google itself, just the FormMail is not properly engaging still.
 
0
•••
Okay! I might have solved it by doing what you suggested (thanks! again), plus adding this line

<input type="hidden" name="derive_fields"
value="imgverify=g-recaptcha-response" />

to just above the
<input type="submit" value="Send Now" class="btn3">
on the xybrand dot com page.

Will keep testing.
 
0
•••
It works!

Wish I could figure out how to get rid of the big space between the Message box and the reCaptcha box.
 
0
•••
I guess the space is okay, can't seem to get rid of it anyway.


One potential issue is when I was testing it, initially, it seemed like if I clicked to submit without filling out the Captcha, yes, it would not allow the sender to submit, it would give sender the blank page with the error message asking sender to go back and do the captcha, but then it seemed like the FormMail would sometimes send along a notification via email of
"FormMail script error"
telling me that the submitter did not provide some required values (missing_fields) namely...the reCaptcha.

Obviously I don't want to be notified every time some spammer fills out the form but doesn't do the Captcha. I hope that was something that just happened while I was setting up the form incompletely.

I couldn't find a setting to turn off notifications of incomplete form submittals, and not sure I'd want to turn all incomplete form notifications off anyway.

Maybe this has something to do with the "attack_detection" setting SilentPtnr mentioned, although I don't think so. We shall see!
 
Last edited:
0
•••
Add ' style="margin:0;" to <div class="g-recaptcha" key=...>" so it become <div class="g-recaptcha" style="margin:0;" key=....">

Then move <input type="hidden" name="derive_fields" value="imgverify=g-recaptcha-response" /> to the top of your form.

Should help a little.

I guess the space is okay, can't seem to get rid of it anyway.


One potential issue is when I was testing it, initially, it seemed like if I clicked to submit without filling out the Captcha, yes, it would not allow the sender to submit, it would give sender the blank page with the error message asking sender to go back and do the captcha, but then it seemed like the FormMail would sometimes send along a notification via email of
"FormMail script error"
telling me that the submitter did not provide some required values (missing_fields) namely...the reCaptcha.

Obviously I don't want to be notified every time some spammer fills out the form but doesn't do the Captcha. I hope that was something that just happened while I was setting up the form incompletely.

I couldn't find a setting to turn off notifications of incomplete form submittals, and not sure I'd want to turn all incomplete form notifications off anyway.

Maybe this has something to do with the "attack_detection" setting SilentPtnr mentioned, although I don't think so. We shall see!
 
0
•••
As far as the preventing the formmail from sending me a form submission even if the user tries to send without filling out the reCaptcha:
$ALERT_ON_USER_ERROR = false;
when set to false, will no longer receive these "FormMail script error"s
telling me that the submitter did not provide some required values (missing_fields) namely...the reCaptcha.

---

mr. x you def. know your coding.
adding
style="margin:0;"
did help narrow the gap a little.

However, moving the
<input type="hidden" name="derive_fields" value="imgverify=g-recaptcha-response" />
to top of form seems to have no effect.
 
Last edited:
0
•••
check kentuckyrv . com

You can have someone from fiver modify that page, ( source is in my sig ) to match your website.
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back