The page in question is located at www.uforecordingsusa.com/contact.asp. I'm integrating reCaptcha ASP code I obtained and having trouble w/ catpcha validation.
I've fixed some minor syntax issues (I think) from the original code as well as expanding the cdoConfig.Fields. I've got Javascript code checking the required contact form fields: Name, Email, Message. This appears to be working fine (I realize there is also ASP authentication for Name and Email further down the page, but I prefer the pop-up window and I figured if this part is working I should just leave it alone).
The captcha displays and refreshes just fine, but it does not appear to be authenticating properly because I can submit the form without entering a captcha - and when I do enter the captcha no email is sent - in both cases, I get no Error or Confirmation message.
Also just to clear up the obvious, I'm sure that I entered the correct variables for Public Key, Private Key, and SMTP settings in the beginning of the form. Any help and constructive comments would be greatly appreciated. Thanks in advance and here's the code (sorry if it's sloppy):
<%@ Language="VBScript" %>
<%
Option Explicit
'Define some variables to be used on page
dim pubkey, privkey, challenge, form_response, show_form, form_feedback, message, email_from, email_to, subject, test_captcha, smtpserver, smtpid, smtppw, url
'Customize your public and private keys and other variables
pubkey = "(removed for forum post)"
privkey = "(removed for forum post)"
smtpserver = "(removed for forum post)"
smtpid = "(removed for forum post)"
smtppw = "(removed for forum post)"
url = "contact.asp"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>UFO Recordings: Make Contact</title>
<meta name="description" content="Make Contact with UFO Recordings. UFO Recordings contact information.">
<meta name="keywords" content="contact ufo recordings, contact the contract killers, contact k-funk, contact auditory groove">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="robots" content="noindex">
<link rel="shortcut icon" href="favicon.ico">
<link href="style.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<script language="javascript" type="text/javascript">
<!--
/***********************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function formCheck(formobj){
// Enter name of mandatory fields
var fieldRequired = Array("name", "email", "comments");
// Enter field description to appear in the dialog box
var fieldDescription = Array("Name", "Email", "Message");
// dialog message
var alertMsg = "Please complete the following field(s):\n";
var l_Msg = alertMsg.length;
for (var i = 0; i < fieldRequired.length; i++){
var obj = formobj.elements[fieldRequired[i]];
if (obj){
switch(obj.type){
case "select-one":
if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "select-multiple":
if (obj.selectedIndex == -1){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "text":
case "textarea":
if (obj.value == "" || obj.value == null){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
default:
}
if (obj.type == undefined){
var blnchecked = false;
for (var j = 0; j < obj.length; j++){
if (obj[j].checked){
blnchecked = true;
}
}
if (!blnchecked){
alertMsg += " - " + fieldDescription[i] + "\n";
}
}
}
}
if (alertMsg.length == l_Msg){
return true;
}else{
alert(alertMsg);
return false;
}
}
// -->
</script>
</head>
<body onLoad="MM_preloadImages('images/h_butt1a.jpg','images/h_butt1b.jpg','images/h_butt2a.jpg','images/h_butt2b.jpg','images/h_butt3a.jpg','images/h_butt3b.jpg','images/h_butt4a.jpg','images/h_butt4b.jpg','images/h_butt5a.jpg','images/h_butt5b.jpg','images/h_butt6a.jpg','images/h_butt6b.jpg','images/h_butt7a.jpg','images/h_butt7b.jpg',)">
<table cellpadding="0" cellspacing="0" border="0" align="center" style="width:768px; height:100%;">
<tr>
<!-- begin of header -->
<td style="width:100%; height:309px; background:url(images/header.jpg) no-repeat top;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; height:100%;">
<tr>
<td style="width:100%; height:45px;">
<div style="margin-left:40px; margin-top:62px;">
<a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('rov1','','images/h_butt1b.jpg',1)"><img src="images/h_butt1a.jpg" alt="" name="rov1" width="61" height="45" border="0"></a><a href="breakbeat.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('rov2','','images/h_butt2b.jpg',1)"><img src="images/h_butt2a.jpg" alt="" name="rov2" width="56" height="45" border="0"></a><a href="events.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('rov3','','images/h_butt3b.jpg',1)"><img src="images/h_butt3a.jpg" alt="" name="rov3" width="72" height="45" border="0"></a><a href="artists.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('rov4','','images/h_butt4b.jpg',1)"><img src="images/h_butt4a.jpg" alt="" name="rov4" width="52" height="45" border="0"></a><img src="images/logo.gif" alt=""><a href="merchandise.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('rov5','','images/h_butt5b.jpg',1)"><img src="images/h_butt5a.jpg" alt="" name="rov5" width="85" height="45" border="0"></a><a href="news.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('rov6','','images/h_butt6b.jpg',1)"><img src="images/h_butt6a.jpg" alt="" name="rov6" width="81" height="45" border="0"></a><a href="contact.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('rov7','','images/h_butt7b.jpg',1)"><img src="images/h_butt7a.jpg" alt="" name="rov7" width="79" height="45" border="0"></a> </div>
</td>
</tr>
<tr>
<td style="width:100%; height:100%;">
</td>
</tr>
</table>
</td>
</tr>
<!-- end of header -->
<tr>
<!-- begin of body -->
<td style="width:100%; height:451px;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; height:100%;">
<tr>
<td style="width:422px; height:100%;">
<table cellpadding="0" cellspacing="0" border="0" style="width:405px; height:100%; margin-left:17px;">
<tr>
<td style="width:100%; height:42px; background:url(images/tt_slice.gif) repeat-x top;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; height:100%; background:url(images/l_side.gif) no-repeat left top;">
<tr>
<td style="width:100%; height:100%; background:url(images/r_side.gif) no-repeat right top;"><img src="images/clearspace.gif" width="40" height="10" alt="" style="margin-top:17px; margin-left:53px;"><span class="style1">Contact UFO Recordings</span><br>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width:100%; height:100%;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; height:100%;">
<tr>
<td style="width:10px; height:100%;"><img src="images/spacer.gif" alt="" width="12" height="1"></td>
<td style="width:100%; height:100%; background:url(images/1b_tab2_tall.gif) repeat-x top #00090A;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; height:100%;">
<tr>
<td style="width:9px; height:9px;"><img src="images/ltc.gif" alt=""><br> </td>
<td style="width:100%; height:9px;"></td>
<td style="width:9px; height:9px;"><img src="images/rtc.gif" alt=""><br> </td>
</tr>
<tr>
<td style="width:9px; height:100%; background:url(images/tab_tall.gif) repeat-y left;"><img src="images/spcer.gif" alt="" width="9" height="1"><br> </td>
<td style="width:100%; height:100%;">
<div style="margin-left:11px; margin-right:11px;">
<br>
<div align="justify" class="style2" style="margin-left:11px; margin-right:11px;">To book a <span class="style3"><strong>UFO Recordings</strong></span> artist for your next event or party, please send us an email using the form below. We will respond to your inquiry as soon as possible, usually within 24 hours.</div>
<br>
<%
'''''''''''''''''''''' BEGIN FUNCTIONS ''''''''''''''''''''''''
'Function to Test Captcha Field
challenge = Request.Form("recaptcha_challenge_field")
form_response = Request.Form("recaptcha_response_field")
function recaptcha_confirm(privkey,rechallenge,reresponse)
' I SUSPECT SYNTAX ERROR(S) HERE...FIRST VARIABLE IN QUOTES HAS NO AMPERSAND, OTHER 3 DO (?)
Dim VarString
VarString = _
"privatekey=" & privkey & _
"&remoteip=" & Request.ServerVariables("REMOTE_ADDR") & _
"&challenge=" & rechallenge & _
"&response=" & reresponse
Dim objXmlHttp
Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXmlHttp.open "POST", "http://api-verify.recaptcha.net/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
'Example Function to Send Email Using CDOSYS
function sendEmail( email_to, subject, message, email_from )
'send email
Dim cdoConfig, cdoMessage
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = smtpid
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = smtppw
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.Subject = subject
.From = email_from
.To = email_to
.TextBody = message
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
end function
'''''''''''''''''''''' END FUNCTIONS ''''''''''''''''''''''''
%>
<%
'''''''''' FORM REQUEST, PROCESSED ON POSTBACK ''''''''''''''
'Form posts back to this page
form_feedback = ""
show_form = true
if Request.Form("submit") <> "" AND Request.Form("submit") = "Send Comment!" then
show_form = false
'Assemble message
subject = "Email From UFO Recordings Website"
message = "Name: " & Request.Form("name") & vbcrlf & "Company: " & Request.Form("company") & vbcrlf & "Email: " & Request.Form("email") & vbcrlf & "Phone: " & Request.Form("phone") & vbcrlf & "Message: " & Request.Form("comments")
'Enter destination e-mail
email_to = smtpid
'EXAMPLE OF BASIC ERROR PROCESSING
'Required - Name
if Request.Form("name") = "" then
form_feedback = form_feedback & "<li>Please enter your name.</li>"
show_form = true
end if
'Required - Email Address
if Request.Form("email") <> "" then
email_from = Request.Form("email")
else
form_feedback = form_feedback & "<li>Please enter your email address.</li>"
show_form = true
end if
'Required - Correct Captcha Value
test_captcha = recaptcha_confirm(privkey, challenge, form_response)
'response.write(test_captcha)
if test_captcha <> "" then
form_feedback = form_feedback & "<li>The entered text does not match, please try again.</li>"
show_form = true
end if
'No Errors on Page, Send E-mail
if show_form = false then
call sendEmail( email_to, subject, message, email_from )
%>
<p>Your comment was sent successfully!</p>
<%
end if
end if
''''''''' END FORM REQUEST, PROCESSED ON POSTBACK ''''''''''''
if show_form = true then
'Display errors to user
if form_feedback <> "" then
%>
<ul style="background: #ffffcc;"><%=form_feedback%></ul>
<% end if
'''''''''''''''''' DISPLAY INITIAL FORM ''''''''''''''''''''''
%>
<form name="contactform" action="<%=url%>" method="post" onSubmit="return formCheck(this);">
<div class="style4">
<table border="0" align="center">
<tr>
<td width="120" align="right" valign="middle" class="style5">* <em>Required</em></td>
<td width="180" valign="middle" class="style3"><img src="images/clearspace.gif" width="1" height="20" alt=""></td>
</tr>
<tr>
<td width="120" align="right" valign="middle" class="style2"><span class="style5">*</span> Name</td>
<td width="180" valign="middle"><input type="text" name="name" value="<%=Request.Form("name")%>" size="30" maxlength="80"></td>
</tr>
<tr>
<td align="right" valign="middle" class="style2">Company</td>
<td valign="middle"><input type="text" name="company" size="30" maxlength="80"></td>
</tr>
<tr>
<td align="right" valign="middle" class="style2"><span class="style5">*</span> Email Address</td>
<td valign="middle"><input type="text" name="email" value="<%=Request.Form("email")%>" size="30" maxlength="80"></td>
</tr>
<tr>
<td align="right" valign="middle" class="style2">Phone Number</td>
<td valign="middle"><input type="text" name="phone" size="30" maxlength="30"></td>
</tr>
<tr>
<td valign="middle" align="right" class="style2"></td>
<td valign="middle"> </td>
</tr>
<tr>
<td valign="middle" align="right" class="style2"><span class="style5">*</span> Message</td>
<td valign="middle"><textarea name="comments" cols="23" rows="5"></textarea>
<br>
</td>
</tr>
</table>
<table align="center" width="90%">
<tr align="right">
<td>
<br>
<p align="center" class="style2"><span class="style5">*</span> Please type the words below</p>
<%
' returns string the can be written where you would like the reCAPTCHA
function recaptcha_challenge_writer(publickey)
recaptcha_challenge_writer = "<script type=""text/javascript"">" & _
"var RecaptchaOptions = {" & _
" theme : 'blackglass'," & _
" tabindex : 0" & _
"};" & _
"</script>" & _
"<script type=""text/javascript"" src=""http://api.recaptcha.net/challenge?k=" & publickey & """></script>" & _
"<noscript>" & _
"<iframe src=""http://api.recaptcha.net/noscript?k=" & publickey & """ frameborder=""1""></iframe><br>" & _
"<textarea name=""recaptcha_challenge_field"" rows=""3"" cols=""40""></textarea>" & _
"<input type=""hidden"" name=""recaptcha_response_field"" value=""manual_challenge"">" & _
"</noscript>"
end function
dim myCaptcha
myCaptcha = recaptcha_challenge_writer(pubkey)
response.write(myCaptcha)
%>
<br>
<input type="submit" name="submit" value="Send Email">
</td>
</tr>
</table>
</div>
</form>
<%
''''''''''''''''' END DISPLAY INITIAL FORM '''''''''''''''''''''
end if %>
</div>
</td>
<td style="width:9px; height:100%; background:url(images/tab_tall.gif) repeat-y right;"><img src="images/spcer.gif" alt="" width="9" height="1"><br> </td>
</tr>
<tr>
<td style="width:9px; height:9px;"><img src="images/lbc.gif" alt=""><br> </td>
<td style="width:100%; height:9px; background:url(images/tab_tall.gif) repeat-x bottom;"></td>
<td style="width:9px; height:9px;"><img src="images/rbc.gif" alt=""><br> </td>
</tr>
</table></td>
<td style="width:11px; height:100%;"><img src="images/spacer.gif" alt="" width="10" height="1"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td style="width:346px; height:100%;">
<table cellpadding="0" cellspacing="0" border="0" style="width:326px; height:100%;">
<tr>
<td style="width:100%; height:221px;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; height:216px;">
<tr>
<td style="width:100%; height:42px; background:url(images/tt_slice.gif) repeat-x top;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; height:100%; background:url(images/l_side.gif) no-repeat left top;">
<tr>
<td style="width:100%; height:100%; background:url(images/r_side.gif) no-repeat right top;"><img src="images/clearspace.gif" width="45" height="10" alt="" style="margin-top:17px; margin-left:53px;"><span class="style1">Visit Our Friends</span><br>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width:100%; height:100%;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; height:100%;">
<tr>
<td style="width:11px; height:100%;"><img src="images/spacer.gif" alt="" width="11" height="1"></td>
<td style="width:100%; height:100%; background:url(images/6b_tab1_tall1.gif) repeat-x top #00090A;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%; height:100%;">
<tr>
<td style="width:9px; height:9px;"><img src="images/ltc.gif" alt=""><br>
</td>
<td style="width:100%; height:9px;"></td>
<td style="width:9px; height:9px;"><img src="images/rtc.gif" alt=""><br>
</td>
</tr>
<tr>
<td style="width:9px; height:100%; background:url(images/tab_tall.gif) repeat-y left;"><img src="images/spcer.gif" alt="" width="9" height="1"><br>
</td>
<td style="width:100%; height:100%;">
<div style="margin-left:11px; margin-right:11px;">
<p class="style2"><strong>UFO Recordings on Myspace</strong><br>
<a href="http://www.myspace.com/uforecordings" target="_blank">www.myspace.com/UFORecordings</a></p>
<p class="style2"><strong>The Contract Killers</strong><br>
<a href="http://www.myspace.com/floridacontractkillers" target="_blank">www.myspace.com/FloridaContractKillers</a></p>
<p class="style2"><strong>K-Funk</strong><br>
<a href="http://www.myspace.com/kfunkazoid" target="_blank">www.myspace.com/KFunkazoid</a></p>
<p class="style2"><strong>DJ MadScratch</strong><br>
<a href="http://www.myspace.com/madnastyscratch" target="_blank">www.myspace.com/MadNastyScratch</a></p>
<p class="style2"><strong>Auditory Groove</strong><br>
<a href="http://www.myspace.com/auditorygroove1" target="_blank">www.myspace.com/AuditoryGroove1</a></p>
<p class="style2"><strong>DJ ONyX</strong><br>
<a href="http://www.myspace.com/velocityproduction" target="_blank">www.myspace.com/VelocityProduction</a></p>
<p class="style2"><strong>DJ Structure</strong><br>
<a href="http://www.myspace.com/structure22" target="_blank">www.myspace.com/Structure22</a></p>
<p class="style2"><strong>DJ Gimme Samoa</strong><br>
<a href="http://www.myspace.com/djgimmesamoa" target="_blank">www.myspace.com/DJGimmeSamoa</a></p>
<p class="style2"><strong>Symphonic Distribution</strong><br>
<a href="http://www.symphonicdistribution.com" target="_blank">www.SymphonicDistribution.com</a></p>
<p class="style2"><strong>Houston Bernard</strong><br>
<a href="http://www.myspace.com/houstonbernard" target="_blank">www.myspace.com/HoustonBernard</a></p>
</div>
</td>
<td style="width:9px; height:100%; background:url(images/tab_tall.gif) repeat-y right;"><img src="images/spcer.gif" alt="" width="9" height="1">
</td>
</tr>
<tr>
<td style="width:9px; height:9px;"><img src="images/lbc.gif" alt=""><br>
</td>
<td style="width:100%; height:9px; background:url(images/tab_tall.gif) repeat-x bottom;"></td>
<td style="width:9px; height:9px;">
</td>
</tr>
</table>
</td>
<td style="width:5px; height:100%;"><img src="images/spacer.gif" alt="" width="5" height="1"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width:100%; height:100%;"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- end of body -->
<tr>
<!-- begin of footer -->
<td style="width:100%; height:100%; background:url(images/f_back.gif) no-repeat top;">
<div style=" line-height:15px; width:100%;" class="footertxt" align="center"> <img src="images/spacer.gif" alt="" width="11" height="1"><a href="index.html" class="footerlink2">home</a>|<a href="breakbeat.html" class="footerlink2">music</a>|<a href="events.html" class="footerlink2">events</a>|<a href="artists.html" class="footerlink2">artists</a>|<a href="merchandise.html" class="footerlink2">merchandise</a>|<a href="news.html" class="footerlink2">news</a>|<a href="contact.html" class="footerlink2">contact</a>|<a href="terms.html" class="footerlink2">terms of use</a>|<a href="privacy.html" class="footerlink2">privacy policy</a>|<a href="sitemap.html" class="footerlink2">site map</a><br>
<br style="line-height:15px;">
© Copyright 2009 UFO Recordings. All rights reserved.<br>
<br style="line-height:10px;">
</div>
</td>
</tr>
<!-- end of footer -->
</table>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-8479783-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>