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.
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.
<!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
%>