ASP‎ > ‎

Using Google reCAPTCHA version 2.0 using classic asp

Google reCAPTCHA version 2 is totally different than the first version.   Here's some code that allows you to use the new "I'm not a robot" version of recaptcha using classic asp.



Dim action, reresponse, recaptchagood
action = request.form("Action")

If action="Go" then

reresponse= Request.form("g-recaptcha-response")

Dim VarString
VarString = _
          "?secret=yoursecretkey&amp;" & _
          "&response=" & reresponse  & _
"&amp;&remoteip=" & Request.ServerVariables("REMOTE_ADDR") 

Dim url
url="" & VarString
  Dim objXmlHttp
  Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP") "POST", url, False
  objXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

  Dim ResponseString
  ResponseString = objXmlHttp.responseText
  Set objXmlHttp = Nothing
If instr(ResponseString, "success" & chr(34) &": true")>0 then
end if
End if


<script src="" async defer></script>
<form action="recaptchatest.asp" method="POST">
 <div class="g-recaptcha" data-sitekey="yoursecretkey"></div>
<input type="hidden" name="Action" value="Go">
      <input type="submit" value="Submit">