Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 29-09-2010, 11:08 PM   #1 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Implementation of google's recaptcha with ASP


A form in a html page (contact.htm) submits the data to asp script
Code:
<form name="test" method="post" action="cdosys.asp">
This code was downloaded from Internet.
I want to implement google lab's recaptcha on my form. I place the following code (as on their website) at the top of the page as rename my file as contact.asp
Code:
<%
  recaptcha_challenge_field  = Request("recaptcha_challenge_field")
  recaptcha_response_field   = Request("recaptcha_response_field")
  recaptcha_public_key       = "6LeYdL0SAAAAAJsYBKQI334EKlophwjQH8MXcma_" ' your public key
  recaptcha_private_key      = "6LeYdL0SAAAAAN8wYCezXdQeFodbYbw80dzVJxYs" ' your private key

  ' returns the HTML for the widget
  function recaptcha_challenge_writer()

  recaptcha_challenge_writer = _
  "<script type=""text/javascript"">" & _
  "var RecaptchaOptions = {" & _
  "   theme : 'clean'," & _
  "   tabindex : 0" & _
  "};" & _
  "</script>" & _
  "<script type=""text/javascript"" src=""http://www.google.com/recaptcha/api/challenge?k=" & recaptcha_public_key & """></script>" & _
  "<noscript>" & _
    "<iframe src=""http://www.google.com/recaptcha/api/noscript?k=" & recaptcha_public_key & """ frameborder=""1""></iframe><>" & _
      "<textarea name=""recaptcha_challenge_field"" rows=""3"" cols=""40""></textarea>" & _
      "<input type=""hidden"" name=""recaptcha_response_field""value=""manual_challenge"">" & _
  "</noscript>"

  end function

  ' returns "" if correct, otherwise it returns the error response
  function recaptcha_confirm(rechallenge,reresponse)

  Dim VarString
  VarString = _
          "privatekey=" & recaptcha_private_key & _
          "&remoteip=" & Request.ServerVariables("REMOTE_ADDR") & _
          "&challenge=" & rechallenge & _
          "&response=" & reresponse

  Dim objXmlHttp
  Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
  objXmlHttp.open "POST", "http://www.google.com/recaptcha/api/verify", False
  objXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  objXmlHttp.send VarString

  Dim ResponseString
  ResponseString = split(objXmlHttp.responseText, vblf)
  Set objXmlHttp = Nothing

  if ResponseString(0) = "true" then
    'They answered correctly
     recaptcha_confirm = ""
  else
    'They answered incorrectly
     recaptcha_confirm = ResponseString(1)
  end if

  end function

  server_response = ""
  newCaptcha = True
  if (recaptcha_challenge_field <> "" or recaptcha_response_field <> "") then
    server_response = recaptcha_confirm(recaptcha_challenge_field, recaptcha_response_field)
    newCaptcha = False
  end if

  %>
As you can see the form sends contents to cdosys.asp when submitted. I don't get how to implement recatcha here.
Any ideas??
Source: Using reCAPTCHA with Classic ASP - reCAPTCHA - Google Code
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com
Sridhar_Rao is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 30-09-2010, 02:59 PM   #2 (permalink)
XLr8
 
arpanmukherjee1's Avatar
 
Join Date: Sep 2008
Posts: 637
Default Re: Implementation of google's recaptcha with ASP

read the following lines ::

Quote:
After you've signed up for your API keys, you can add reCAPTCHA
use this:

Sign up for an API Key - Google Base Data API - Google Code
__________________
Quote:
There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy.
arpanmukherjee1 is offline   Reply With Quote
Old 30-09-2010, 06:00 PM   #3 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Re: Implementation of google's recaptcha with ASP

Procuring the public and private keys was the first step. The keys are in right place, that is not the issue here.
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com
Sridhar_Rao is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:22 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2