Posts for 10th August 2010

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>
...

A modified nms FormMail script is available for download.