troubleshooting Question

recaptcha asp form

Avatar of franco_c
franco_c asked on
ASPASP.NET
3 Comments1 Solution1062 ViewsLast Modified:
Hi All,
I have a "contact form" that I would like the information to be emailed to "sales2010@mycompany.com". I know very little about asp, I have used recaptcha with php forms but i am forced to use asp here.

I am posting the code for the target of the form on the page: http://www.toplinesign.com/default.asp

it is an echo of the form: http://www.toplinesign.com/form2.asp, after captcha is confirmed

I would like to alter this code so after it is confirmed as recaptcha approved it is emailed to my client.

thanx,
FGC

<%@ LANGUAGE="VBScript" %>
<!--#include file="ASPlibrary/adovbs.asp"-->
<!--#include file="ASPlibrary/iasutil.asp"-->
<%
' On Error Resume Next

contact_firstname          = SQLEncode(Request("contact_firstname"))
contact_lastname           = SQLEncode(Request("contact_lastname"))
contact_company            = SQLEncode(Request("contact_company"))
contact_address            = SQLEncode(Request("contact_address"))
contact_city               = SQLEncode(Request("contact_city"))
contact_state              = SQLEncode(Request("contact_state"))
contact_zip                = SQLEncode(Request("contact_zip"))
contact_email              = SQLEncode(Request("contact_email"))
contact_tel                = SQLEncode(Request("contact_tel"))
contact_fax                = SQLEncode(Request("contact_fax"))
contact_text               = SQLEncode(Request("contact_text"))
recaptcha_challenge_field  = Request("recaptcha_challenge_field")
recaptcha_response_field   = Request("recaptcha_response_field")
recaptcha_private_key      = "6Ld5OL0SAAAAAIQ5NKa2M466vlherxj2Xa8M5EwA"
recaptcha_public_key       = "6Ld5OL0SAAAAAOE6EEFKr8sDNxqxyXYj8A5qKB_P"
browser                    = Request.ServerVariables("HTTP_USER_AGENT")
ip                         = Request.ServerVariables("REMOTE_HOST")
%>

<html>
<head>

<title>.: Top Line Advertising ~ Contact us at Top Line Advertising :.</title>

<script type= "text/javascript">
var RecaptchaOptions = {
theme: 'clean'
};
</script>

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

      <link rel="shortcut icon" href="favicon.ico" >


	
<link href="tls_2010v2.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />



</head><body>
<div id="frame">

	<div id="tls_Header"><img src="images/header2010_LOGO.jpg" width="900" height="125" />    </div>
    

    <!-- #BeginLibraryItem "/Library/tls_Nav2010v2.lbi" -->
<DIV ID="nav" align="left" valign="top">
        <ul id="nav">
                <li id="navTop-home"><a href="index.htm">Home</a></li>
				<li id="navTop-testimonials"><a href="about.htm">Who We Are</a></li>
                <li id="navTop-service"><a href="manufacturing.htm">Manufacturing</a></li>
          <li id="navTop-repair"><a href="installation.htm">Installation</a></li>
                <li id="navTop-portfolio"><a href="portfolio.htm">Portfolio</a></li>
                <li id="navTop-contact"><a href="contact.htm">Contact Us</a></li> 
  </ul>
       
        
</DIV><!-- #EndLibraryItem --><div id = "title"> </div>

<div id="mainContent">

    <h1>Confirm . . .</h1>
    <div class="testiText">
        <p>&nbsp;</p>

        <br>
	</div>
<% 
cTemp = recaptcha_confirm(recaptcha_private_key, recaptcha_challenge_field, recaptcha_response_field)
If cTemp <> "" Then 
%>

  <p>An error occured with the recapture wording. Please try again. The error was <b><%=cTemp%></b></p>

       
    <div class="imgLrgForm">
  <form action="form2.asp" method="post">
<table cellspacing="2" cellpadding="0" border="0" width="530">
  <tr>
    <td align="right" width="140">First Name:</td>
    <td width="390"><input name="contact_firstname" style=" width: 150px;" class="textSize2 black" type="text" value="" maxlength="50"></td>
  </tr>
  <tr>
    <td align="right">Last Name:</td>
    <td><input name="contact_lastname" style=" width: 150px;" class="textSize2 black" type="text" value="" maxlength="50"></td>
  </tr>
  <tr>
    <td align="right">Company:</td>
    <td><input name="contact_company" style=" width: 200px;" class="textSize2 black" type="text" value="" maxlength="150"></td>
  </tr>
   <tr>
    <td align="right">Address:</td>
    <td><input name="contact_address" style=" width: 200px;" class="textSize2 black" type="text" value="" maxlength="150"></td>
  </tr>
   <tr>
    <td align="right">City:</td>
    <td><input name="contact_city" style=" width: 200px;" class="textSize2 black" type="text" value="" maxlength="150"></td>
  </tr>  <tr>
    <td align="right">State:</td>
    <td><input name="contact_state" style=" width: 200px;" class="textSize2 black" type="text" value="" maxlength="150"></td>
  </tr> 
   <tr>
    <td align="right">Zip:</td>
    <td><input name="contact_zip" style=" width: 200px;" class="textSize2 black" type="text" value="" maxlength="150"></td>
  </tr>  
   <tr>
    <td align="right">Email Address:</td>
    <td><input name="contact_email" style=" width: 200px;" class="textSize2 black" type="text" value="" maxlength="150"></td>
  </tr>
    <tr>
    <td align="right">Phone Number:</td>
    <td><input name="contact_tel" style=" width: 100px;" class="textSize2 black" type="text" value="" maxlength="30"></td>
  </tr>
  <tr>
    <td align="right">Fax Number:</td>
    <td><input name="contact_fax" style=" width: 100px;" class="textSize2 black" type="text" value="" maxlength="30"></td>
  </tr>
   <tr>
    <td colspan="2">&nbsp;</td>
  </tr>

  <tr>
    <td align="right" valign="top">Human Check:</td>
    <td><%=recaptcha_challenge_writer(recaptcha_public_key)%></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="top" width="140">Additional information you would like us to know (optional)</td>
    <td><textarea cols="30" name="contact_text" class="textSize2 black" rows="5"></textarea></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" value=" Submit " name="submit1"></td>
  </tr>
</table>
  </form>
  
  
  
  </div>
<% Else %>

  <p>Thank you. The recaptcha match worked. A summary of your Form Data is listed below. Back to <a href="default.asp">Home Page</a></p>

  <p><table cellspacing="2" cellpadding="2" border="0" width="530">
<table cellspacing="2" cellpadding="0" border="0" width="530">
  <tr>
    <td align="right" width="140">First Name:</td>
    <td width="390"><%=contact_firstname%></td>
  </tr>
  <tr>
    <td align="right">Last Name:</td>
    <td><%=contact_lastname%></td>
  </tr>
  <tr>
    <td align="right">Company:</td>
    <td><%=contact_company%></td>
  </tr>
   <tr>
    <td align="right">Address:</td>
    <td><%=contact_address%></td>
  </tr>
   <tr>
    <td align="right">City:</td>
    <td><%=contact_city%></td>
  </tr>  <tr>
    <td align="right">State:</td>
    <td><%=contact_state%></td>
  </tr> 
   <tr>
    <td align="right">Zip:</td>
    <td><%=contact_zip%></td>
  </tr>  
   <tr>
    <td align="right">Email Address:</td>
    <td><%=contact_email%></td>
  </tr>
    <tr>
    <td align="right">Phone Number:</td>
    <td><%=contact_tel%></td>
  </tr>
  <tr>
    <td align="right">Fax Number:</td>
    <td><%=contact_fax%></td>
  </tr>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td align="right" valign="top" width="140">Text:</td>
      <td><%=contact_text%></td>
    </tr>
  </table>

</table></p>

<% End If %>
<%
' The code below supplied by Mark Short 

' returns string the can be written where you would like the reCAPTCHA challenged placed on your page 
function recaptcha_challenge_writer(publickey) 
  recaptcha_challenge_writer = "<script type=""text/javascript"">" & _ 
  "var RecaptchaOptions = {" & _ 
  " theme : 'white'," & _ 
  " 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 

function recaptcha_confirm(privkey,rechallenge,reresponse) 
  ' Test the captcha field 
  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 
%>
</div>


  <!-- end #mainContent --></div>

<!-- #BeginLibraryItem "/Library/tls_Footer2010.lbi" -->
<DIV ID="footer" align="center" valign="top">
      <BR/>
        <ul id="navFooter">
              <li id="navFooter">|</li>
                <li id="navFooter-home"><a href="index.htm">Home</a></li>
                <li id="navFooter">|</li>
				<li id="navFooter-testimonials"><a href="about.htm">Who We Are</a></li>
                <li id="navFooter">|</li>
                <li id="nav-service"><a href="manufacturing.htm">Manufacturing</a></li>
          <li id="navFooter">|</li>
                <li id="nav-repair"><a href="installation.htm">Installation</a></li>
                <li id="navFooter">|</li>                
                <li id="nav-portfolio"><a href="portfolio.htm">Portfolio</a></li>
                <li id="navFooter">|</li>
                
                
                <li id="nav-contact"><a href="contact.htm">Contact Us</a></li> 

                <li id="navFooter-::">|</li>
                <li id="navFooter-siteMap"><a href="siteMap.htm">Site Map</a></li>
             <li id="navFooter-::">|</li>
  </ul>
       
        
</DIV>       

<Div ID="copyRight" align="center" bgcolor="#000000"> 

All of this information is the copyright © 2010 of Top Line Advertising • Maple Grove, MN 55369</Div>

 
<!-- #EndLibraryItem --></div>
</body>
</html>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros