Captcha into ASP mail form script - Posted (1889 Views)
Junior Member
Zenfor
Posts: 372
372
Hi,

I have a standard asp mail form script I have been using with a randomized number check yet I still get a lot of spam and nuisance emails. Does anyone know of a ready made script or where I can get a captcha routine that I can insert into my existing script? or does anyone have any ideas on how I can eliminate emails completed by bots?
Thanks!
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Average Member
Webbo
Posts: 982
982
Here you are: http://www.snitzbitz.com/mods/details.asp?Version=All&mid=230

Posted
Advanced Member
Carefree
Posts: 4224
4224
Webbo, Zenfor wants "non-forum related" advice. CAPTCHA routines made to integrate into Snitz aren't the ideal solution.
That said, there are pros and cons for using CAPTCHA at all. Some advise NEVER to use them; but spam-bots will bury you if you don't. I cannot recommend any particular anti-spam routine from the information provided.
You could do something like this, you would have to edit the database path and put images titled "a"-"z" and "0"-"9" into an images folder. The database would require a table titled "CAPTCHA" with two fields (DTG) and (Captured), both of which set to varchar(16).
This method would write the CAPTCHA into the database set to the exact second of its creation (to preclude duplicates). When the user submits the form for validation, the CAPTCHA is deleted from the table.
"inc_captcha.asp"
Code:

<!DOCTYPE HTML>
<%
On Error Resume Next
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database.mdb") ' ## MS Access 2000 using virtual path
set my_Conn = Server.CreateObject("ADODB.Connection")
my_Conn.Errors.Clear
Err.Clear
my_Conn.Open strConnString

Function doublenum(fNum)
If fNum > 9 Then
doublenum = fNum
Else
doublenum = "0" & fNum
End If
End Function

If Request.Form("DTG") > "" Then
strSql="SELECT * FROM CAPTCHA WHERE DTG='" & Request.Form("DTG") & "' AND CAPTURED='" & Request.Form("Captured") & "'"
Set rsCheck=my_Conn.Execute(strSql)
If not rsCheck.EOF Then
' CAPTCHA Matches, continue
rsCheck.Close
my_Conn.Execute("DELETE * FROM CAPTCHA WHERE DTG='" & Request.Form("DTG") & "' AND CAPTURED='" & Request.Form("Captured") & "'")
Response.Write "Correct ..."
Response.End
Else
' CAPTCHA Fails, do something here
Response.Write "CAPTCHA Failed<br /><br />"
my_Conn.Execute("DELETE * FROM CAPTCHA WHERE DTG='" & Request.Form("DTG") & "'")
End If
Set rsCheck = Nothing
End If
strCap="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
intI=62
strCaptured=""
strCapture=""
Randomize
a=int(rnd*5)+3
For i = 1 to a
Randomize
j=int(rnd*intI)+1
strA=uCase(mid(strCap,j,1))
Response.Write "<img src=""images/" & strA & ".png"" height=""24"" width=""24"">"
strCapture=strCapture & cStr(j)
strCaptured=strCaptured&strA
Next
Response.Write "       "
strCaptured=strCaptured&" "
Randomize
a=int(rnd*5)+3
For i = 1 to a
Randomize
j=int(rnd*intI)+1
strA=uCase(mid(strCap,j,1))
Response.Write "<img src=""images/" & strA & ".png"" height=""24"" width=""24"">"
strCapture=strCapture & cStr(j)
strCaptured=strCaptured&strA
Next
strDateNow = Year(Now())&DoubleNum(Month(Now()))&DoubleNum(Day(Now()))
strTimeNow = DoubleNum(Hour(Now()))&DoubleNum(Minute(Now()))&DoubleNum(Second(Now()))
strNow = strDateNow & strTimeNow
strSql="INSERT INTO CAPTCHA (DTG,CAPTURED) VALUES ('" & strNow & "', '" & strCaptured & "')"
my_Conn.Execute(strSql)

Response.Write "<form action=""inc_captcha.asp"" method=""post"">" & vbNewLine & _
" <input type=""hidden"" name=""DTG"" value=""" & strNow & """>" & vbNewLine & _
" Enter the two images below:<br /><input type=""text"" name=""Captured"" size=""30"" maxlength=""17"" value="""">" & vbNewLine & _
" <input type=""submit"" name=""submit"">" & vbNewLine & _
"</form>" & vbNewLine
%>
Posted
Junior Member
Zenfor
Posts: 372
372
Thanks for the replies. I'm glad I posted this here because it got me thinking, as a result, I think I solved it. I think they were bypassing the entry form and going right into the "processing of the form script". I put a check at the beginning of that now to verify the form random number. I won't know for sure unless I don't see them come in - my fingers are crossed... Thanks!
Posted
Average Member
Webbo
Posts: 982
982
Originally posted by Carefree
Webbo, Zenfor wants "non-forum related" advice. CAPTCHA routines made to integrate into Snitz aren't the ideal solution......

Whoops, I never saw the forum title, just the post - my eyes bad lol
 
You Must enter a message