Can anyone look at my Classic ASP code w/reCaptcha to see what I need to change. The form works, except for the reCaptcha part...I can't figure it out. When I click on submit the form processes the info and send the email...but bypasses the reCaptcha part.
<% Option Explicit %>
<!-- #include file="adovbs.inc" -->
<%
recaptcha_challenge_field = Request("recaptcha_challenge_field")
recaptcha_response_field = Request("recaptcha_response_field")
recaptcha_public_key = "I have info in form" ' your public key
recaptcha_private_key = "I have info in form" ' your private key
' returns the HTML for the widget
function recaptcha_challenge_writer()
recaptcha_challenge_writer = _
"<script type=""text/javascript"">" & _
"var RecaptchaOptions = {" & _
" theme : 'red'," & _
" 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
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language='javascript' type='text/javascript' src='libraryvalidatecontact.js'></script>
<title>Harold Washington College Library Contact General Request Form</title>
</head>
<body>
<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" summary="AV Service Request Form.">
<tr valign='top'>
<td width='100%' align='left'>
<form style="margin-bottom: 0" action="libraryprocesscontact.asp" method="POST" onSubmit="return validateForm(this);">
<table width='100%' summary='Online Registration Form.'>
<tr valign='top'>
<td width='100%' align='left'>
<table width='100%' summary='Instructor Information Section.'>
<tr valign='middle'>
<td align='center'><b>HWC LIBRARY CONTACT GENERAL REQUEST FORM:</b></td>
</tr>
<tr valign='middle'>
<td align='center'><b>Asterisk <font color="red">(*)</font> denotes required field.</b></td></tr>
<tr valign='middle'><td align='center'> </td></tr>
</table>
</td>
</tr>
<tr valign='top'>
<td width='100%' align='left'>
<table width='100%' align='left' summary='Name Field'>
<tr valign='middle'>
<td align='right' width='45%' class='redl'>
<font color="#FF0000">*</font>
<LABEL for='First Name:' class='blkl'><b>First Name:</b></LABEL>
</td>
<td align='left' width='55%'>
<input type='text' name='fname' size='20' value='' id=''>
</td>
</tr>
<tr valign='middle'>
<td align='right' width='45%' class='redl'>
<font color="#FF0000">*</font>
<LABEL for='Last Name:' class='blkl'><b>Last Name:</b></LABEL>
</td>
<td align='left' width='55%'>
<input type='text' name='lname' size='20' value='' id=''>
</td>
</tr>
<tr valign='middle'>
<td align='right' width='45%' class='redl'>
<font color="#FF0000">*</font>
<LABEL for='Email Address:' class='blkl'><b>Email Address:</b></LABEL>
</td>
<td align='left' width='55%'>
<input type='text' name='email' size='20' value='' id=''>
</td>
</tr>
<tr valign='top'>
<td align='right' width='45%'>
<LABEL for='Comment/Question:'><b>Comment/Question:</b></LABEL>
</td>
<td align='left' width='55%'>
<textarea name='comments' cols='20' rows='5' id=''></textarea>
</td>
</tr>
</table>
</td>
</tr>
<tr valign='middle'>
<td width='100%' align='center'>
<table width='100%' summary='Class Dates and Submission Buttons.'>
<tr valign='middle'>
<td align='center' width='100%'>
<b>SPAM Guard:</b> Please verify that you are not a SPAM robot by
entering the characters shown in the box below:
</td>
</tr>
</table>
</td>
</tr>
<tr valign='middle'>
<td width='100%' align='center'>
<table width='100%' summary='Class Dates and Submission Buttons.'>
<tr valign='middle'>
<td align='center' width='100%'>
<% if server_response <> "" or newCaptcha then %>
<% if newCaptcha = False then %>
<!--- An error occurred --->
Wrong!
<% end if %>
<!--- Generating the form --->
<form action="recaptcha.asp" method="post">
<%=recaptcha_challenge_writer()%>
</form>
<% else %>
<!-- The solution was correct -->
Correct!
<%end if%>
</td>
</tr>
</table>
</td>
</tr>
<tr valign='top'>
<td width='100%' align='center'>
<table width='100%' summary='Class Dates and Submission Buttons.'>
<tr><td align='center'><LABEL for='Submit by Email'> </LABEL><input type='Submit' value='Submit by Email' id='Submit by Email'></td></tr>
<tr>
<td align='center'>Please submit any additional comments and/or questions to:</td>
</tr>
<tr>
<td align='center'><b>Dennis Macklin, HWC Library Research Specialist, Room 501</b></td></tr>
<tr><td align='center'><b>Phone #:
312.553.5600</b></td></tr>
</table>
</td>
</tr>
</table> <!-- End of table form -->
</form>
</td>
</tr>
</table>
</body>
</html>