Does anyone know how to add a recaptcha to a Cold Fusion form? The form should not submit until the recaptcha has been checked off. I keep finding everything with PHP for this, but nothing with a Cold Fusion form. Here’s a simple form I created below. I’m not sure how to put the code in a special box here. I also left the Secret Key and Site key off of here on purpose.
Rick, I’m not recalling that custom tags can be disabled. You can easily confirm, though.
- Create a file called bob.cfm, doing some simple cfoutput or cfdump, and then run it as bob.cfm to confirm it works.
- Then create a file called sally.cfm and in that one, simply do this: <cf_bob>, and run it as sally.cfm. If it works it will show the output from Bob, and you’ve proven you CAN call custom tags.
If your concern may be that you want to store the template (called as a tag) in a different folder, you could explore using cf’s application-level “mappings” feature.
You could also try using instead the cfmodule tag as an alternative way to call a template as a custom tag. It offers a template attribute that lets you name the path to the template.
Let us know if any of these get you going.
Jamie, to answer your first question, yes it is possible to leverage google’s recaptcha in a CF form.
Of course, it’s really a javascript library, but many do want to integrate it with CFML more specifically, just like you say you find discussions of integrating with PHP and such. And while you may be looking for help to diagnose whatever may be amiss with your code, and someone may well want to jump in to diagnose that, I will offer a different solution.
There are multiple existing CFML solutions to leveraging recpatcha, and you can either switch to using one of those (like I do), or you can at least look at their code to see how it works and why yours does not.
The one I use is this: https://github.com/jeffpratt/ColdFusion-No-CAPTCHA-reCAPTCHA. It’s a simple CFML custom tag. All you have to do is put your Google keys for your repatcha account into the recaptcha.cfml file. The repo explains that process and offers that code.
The repo also offers a sample to test calling it, and it’s just a few lines of code that you could roll into your own form (to call the custom tag, and test its results). Again, it’s the one I use and it does work (even in CF2018).
There are still others, which you or others may want to look into also (I have not tested them so don’t know if they still work). Most are indeed years old, but the recaptcha stuff has not changed much. See the following (and any comments in blog posts or issues in github repos):
- https://cfdeepak.wordpress.com/2014/12/05/google-new-recaptcha-using-coldfusion/
- https://github.com/stevewithington/ReCAPTCHA
- https://github.com/CreativeNotice/cf-recaptcha
Let us know if one of those gets you going.
You must be logged in to post a comment.