Skip to content

Instantly share code, notes, and snippets.

@dkumar431
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dkumar431/9432e0c6dee3a5141b0c to your computer and use it in GitHub Desktop.
Save dkumar431/9432e0c6dee3a5141b0c to your computer and use it in GitHub Desktop.
<cfparam name="FORM.username" default="" type="string" >
<cfparam name="FORM.password" default="" type="string" >
<cfif structKeyExists(FORM,"submit")>
<cfset recaptcha = FORM["g-recaptcha-response"] >
<cfif len(recaptcha)>
<cfset googleUrl = "https://www.google.com/recaptcha/api/siteverify">
<cfset secret = "6LctadUSAAAAAM7NPoPq5jlbm3a37ib3sHlRFyNE">
<cfset ipaddr = CGI.REMOTE_ADDR>
<cfset request_url = googleUrl & "?secret=" & secret & "&response=" & recaptcha & "&remoteip" & ipaddr>
<cfhttp url="#request_url#" method="get" timeout="10">
<cfset response = deserializeJSON(cfhttp.filecontent)>
<cfif response.success eq "YES">
<!--- Start validating the username/password here. --->
</cfif>
</cfif>
</cfif>
<!DOCTYPE html>
<html>
<head>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<form method="post">
UserName:
<input type="text" name="username">
<br><br>
Password:
<input type="password" name="password">
<br><br>
<div class="g-recaptcha" data-sitekey="6LctadUSAAAAAI81jKmWaBFGWwMky64xbBGhVl8L"></div>
<input type="submit" value="Submit" name="submit">
</form>
</body>
</html>
@tucq88
Copy link

tucq88 commented Feb 4, 2015

Could not get this work. I got Element G is undefined in FORM. error :( Can you help ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment