This post is the second in a series of posts describing the changes required to add reCAPTCHA to nmsFormMail.

With the changes outlined in part I in place a call to FormMail can be modified to use reCaptchas as follows...

Add a hidden field that specifies where nms should re-direct to if the CAPTCHA fails

...
<input name="captcha_fail_redirect" value="http://www.yousite.com/contact_captcha_fail.htm" type="hidden">
...

Add a javascript call to reCaptcha, replacing 'your_public_key' with your public key.

...
  <script type="text/javascript" 
    src="http://www.google.com/recaptcha/api/challenge?k=your_public_key"> 
  </script> 
...

And for those without javascript, again replacing 'your_public_key' with your public key...


...
<noscript> 
    <iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key" 
        height="300" width="500" frameborder="0"></iframe> 

    <textarea name="recaptcha_challenge_field" rows="3" cols="40"> 
    </textarea> 
    <input type="hidden" name="recaptcha_response_field" 
        value="manual_challenge"> 
  </noscript>
...
August 10, 2010

Add a comment

Comments

  • Hi,

    Thank you for taking the time to provide this very useful Captcha solution!

    I have to admit I am having a little problem with following what needs to be done and would appreciate a little help.

    I have downloaded your Formmail Script in Part one, made the changes you highlight to personalise it to my domain, private key. and when I test the form it allows the form to be sent without checking the Captcha input data! I notice in Part 2 that you talk of adding more information, but to me it is not clear where this info. is expected to be placed? ...in my HTML/PHP file ? and if so where in the Head/Body? or is this further changes to the Formamil script itself?

    Basically would these extra changes in Part 2 solve my problem of verification of Captcha input?

    Any clarification would be much appreciated!

    Kind Regards,

    john R.
    Written on October 8, 2014 by John R
  • Hi John,

    In order to use the script outlined in Part One it is necessary to add the code fragments in Part II to the page where you are sending an email.

    In addition to get the reCaptcha form to display follow the instructions at https://developers.google.com/recaptcha.
    Written on October 8, 2014 by Ross