Print Page | Close Window

CAPTCHA Code Still Not Working

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz CAPTCHA
Forum Description: Support forum for the Web Wiz CAPTCHA security image.
URL: https://forums.webwiz.net/forum_posts.asp?TID=21925
Printed Date: 28 March 2026 at 4:57pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: CAPTCHA Code Still Not Working
Posted By: Tomcat
Subject: CAPTCHA Code Still Not Working
Date Posted: 14 November 2006 at 8:08pm
I have read through all of the posts on Captcha (found by keyword search) and tried troubleshooting, but still can't get it to work.  Perhaps my understanding of how the programs work and fit together is foggy.
 
Here is my latest error message:
 

Microsoft VBScript compilation error '800a0411'

Name redefined

/hauntedhouse/CAPTCHA/CAPTCHA_setup.asp, line 54

Dim blnCAPTCHAabout

----^

I am not sure where I need to declare this variable.

Here is the Captcha code that is INSIDE my form:
 
<!-- include the Web Wiz CAPTCHA form -->

<!--#include file="CAPTCHA/CAPTCHA_form_inc.asp" -->

<br>

<p><span class="style7">Enter the code exactly as you see it in the image:-<br />

    (Cookies must be enabled)</span><br />

    &nbsp;</p>

 

<!-- Include file for CAPTCHA form processing -->            

<!-- #include file="CAPTCHA/CAPTCHA_process_form.asp" -->          

 

<%

 

'Above we include the file that checks to see if the security code is correct

 

'The variable 'blnCAPTCHAcodeCorrect' will be set to true if the security code is entered correctly

 

If blnCAPTCHAcodeCorrect Then

           

            Response.Write("Correctly")

Else

 

            Response.Write("Incorrectly")

End If

             

%>
 
I didn't write any other conditions yet because I wanted to see if it passed through the first step.
 
I am using CDONTS for my email processesor.  So I have a emailform.asp file that processes the CDONTS email component.
 
So there are three key files:  the form file, the CDONTS file, and the Thank You file that the user gets when the form results were successfully emailed.
 
Please someone help me.   Thanks greatly.


-------------
Tomcat



Replies:
Posted By: WebWiz-Bruce
Date Posted: 15 November 2006 at 9:56am
The error means you are declaring the variable multiple times. You can only use the following line once in a file:-

Dim blnCAPTCHAabout


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: Tomcat
Date Posted: 15 November 2006 at 12:26pm

I must be confused as to what file includes should be in my form.

My form includes my own variables and then includes two files:
CAPTCHA/CAPTCHA_form_inc.asp and CAPTCHA/CAPTCHA_process_form.asp
 
From what I understand, the CAPTCHA_form_inc.asp file has the captcha field and the CAPTCHA_process_form.asp file checks to see if the security code was properly entered.
 
The CAPTCHA_form_inc.asp file calls CAPTCHA_setup.asp by an #include which
initializes the blnCAPTCHAabout variable.  The CAPTCHA_form_inc.asp file  uses  the variable blnCAPTCHAabout, which refers to the copyright.
 
The CAPTCHA_process_form.asp also calls the CAPTCHA_setup.asp files that again initializes the blnCAPTCHAabout variable.
 
Since I should not make any changes to your code, I am at a loss as what to do.  I was thinking that the code to check the correctness of captcha entry should be in the same form file with the rest of the form fields.  In order for that to happen, both the CAPTCHA_form_inc.asp and the CAPTCHA_process_form.asp files need to be in the same form file.  Right? Or am I missing something.  Both of these files include the CAPTCHA_setup.asp which initializes the blnCAPTCHAabout variable.  So I understand your comment.
 
But, what should I do to accomplish what I need without changing any of the code in your CAPTCHA files?
 
Sorry that I am such a newbie.  Please light my lightbulb!  Thanks.
 
 
 
 


-------------
Tomcat


Posted By: bobmac
Date Posted: 18 November 2006 at 11:34pm
I'm also stuck on the same issue. Hopefully, someone will shed some light on how to solve this. Meanwhile, I'm stumped and stopped!  Cry

-------------
Bob McIntyre


Posted By: dpyers
Date Posted: 18 November 2006 at 11:59pm
Originally posted by bobmac bobmac wrote:

I'm also stuck on the same issue. Hopefully, someone will shed some light on how to solve this. Meanwhile, I'm stumped and stopped!  Cry

http://forums.webwiz.net/forum_posts.asp?TID=21951 - http://forums.webwiz.net/forum_posts.asp?TID=21951

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: bobmac
Date Posted: 19 November 2006 at 12:10am
Thanks, but I don't think that link solves my issue. Mine is one where as soon as I attempt to load the page with <!-- #include file="CAPTCHA/CAPTCHA_process_form.asp" --> at the very top of the page with the other include files and <!--#include file="CAPTCHA/CAPTCHA_form_inc.asp" --> in the spot where I want the CAPTCHA to appear (right above the submit button), I get an error page with 

Microsoft VBScript compilation error '800a0411'

Name redefined

/CAPTCHA/CAPTCHA_setup.asp, line 54

Dim blnCAPTCHAabout
----^

I'm just trying to get the page loaded. Is that any clearer? (After I get this one fixed, then I'll go on to the variables issue.)


-------------
Bob McIntyre


Posted By: dpyers
Date Posted: 19 November 2006 at 4:42am
CAPTCH can't be used in a form that submits to itself.
<!--#include file="CAPTCHA/CAPTCHA_form_inc.asp" --> goes into the .asp form page
<!-- #include file="CAPTCHA/CAPTCHA_process_form.asp" --> goes into a different .asp form handler page.


-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Davecl
Date Posted: 22 November 2006 at 7:10am
Originally posted by dpyers dpyers wrote:

CAPTCH can't be used in a form that submits to itself.
 
i believe it can, i got it working on a registration form written in DW8.02, however after probs with 8.02 i have gone back to 8.01 and can't get it working, i will keep trying though and let you know when(if) i get it working Tongue


Posted By: dpyers
Date Posted: 22 November 2006 at 3:01pm
You actually can get it to work on a form that submits to itself, to use multiple forms in different directories with one captcha, to use more than one form on a page, and to use it with a .net postback. But the advanced usage isn't supported by Borg.
 
Too many path and/or javascript and mods need to be done by the user to make them work. Became a support horror show so I believe Borg opted to KISS.


-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Davecl
Date Posted: 22 November 2006 at 3:02pm
done it Smile
here goes
 
first in CAPTCHA_process_form.asp find this code (top of file)

<!-- #include file="CAPTCHA_setup.asp" -->
<%
'****************************************************************************************
'**  Copyright Notice
'**
'**  Web Wiz Guide - Web Wiz CAPTCHA
'** 
'**  http://www.webwizCAPTCHA.com - http://www.webwizCAPTCHA.com
'**
 
and remove the line in red, this is to prevent the variable blnCAPTCHAcodeCorrect being dimmed twice and causing an error.
 
Next insert 
<!--#include file="CAPTCHA/CAPTCHA_form_inc.asp" -->
in your form as normal.
 
I am assuming we are using dreamweaver here as this is the most common application that creates forms that post to the same page.
My example here is from a registration page which creates an insert into database behaviour, so next we need to find where dreamweaver sets up the insert statement.
 

<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) = "frmregister") Then
  MM_editConnection = MM_ConnTenerife_STRING
  MM_editTable = "Members"
  MM_editRedirectUrl = "mailform.asp"
  MM_fieldsStr  = "fldregusername|value|fldregpassword|value|fldname|value|fldemail|value"
  MM_columnsStr = "fldusername|',none,''|fldpassword|',none,''|fldName|',none,''|fldEmail|',none,''"
  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
 
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next
  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.Querystring <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.Querystring <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.Querystring
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.Querystring
    End If
  End If
End If
%>
 
incidentally for those of you wanting to pass form variables to another page after the insert (which you can't do with code generated by dreamweaver) then change the blue bits of the code above to
Request.Form
and now you can Smile I use this myself on this registration page and after the new record is inserted it passes the form variables to a page that sends the new user a confirmation email.
anyway, i digress, back to the CAPTCHA.
 
Find the code above and add the bits in red in this next section of code

 <!-- #include file="CAPTCHA/CAPTCHA_process_form.asp" -->
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")) = "frmregister") Then
If blnCAPTCHAcodeCorrect = True Then
  MM_editConnection = MM_ConnTenerife_STRING
  MM_editTable = "Members"
  MM_editRedirectUrl = "mailform.asp"
  MM_fieldsStr  = "fldregusername|value|fldregpassword|value|fldname|value|fldemail|value"
  MM_columnsStr = "fldusername|',none,''|fldpassword|',none,''|fldName|',none,''|fldEmail|',none,''"
  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
 
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next
  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.Querystring <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.Querystring <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.Querystring
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.Querystring
    End If
  End If
ElseIf  blnCAPTCHAcodeCorrect = False Then
   Response.Redirect("wrongcode.asp")
  End If
End If
%>
 
That's it, done Smile


-------------
Dave "my head hurts" Clarke


Posted By: bobmac
Date Posted: 28 November 2006 at 6:58am
Thanks, Davecl...

But I'm not even doing the database thing. We've been using WebAssist Universal Email to simply generate an email to the client based on the info entered into the form. They just use the info they get by email to contact the prospect. No database.

Spammers have started to post to the form, hence we want to use CAPTCHA. But, even tho there's no database, we still get the "name redefined" thing.

I just need help getting the CAPTCHA to prevent scripts from using the form. Nothing more. So all the insert stuff is not pertinent.

Is that any clearer? Can anyone help with this one?

BTW, if you haven't guessed by now, I'm a designer, not a coder...

TIA...


-------------
Bob McIntyre


Posted By: Davecl
Date Posted: 29 November 2006 at 6:38am
hi bob
 
does the form post to the same page or another page??
 
pm me the code if you like and i'll take a look if i get chance


Posted By: lowgenius
Date Posted: 19 December 2006 at 1:56pm
Dave -

This is a very interesting solution to the issue of duplicate calls to CAPTCHA_Setup.asp.  I wonder, though...it looks to me as though you're cutting the include file from the first place it's called - the form processor file - and leaving it in the second place it's called (the actual CAPTCHA include file).  This seems counter-intuitive to me...

If I have a single-page e-mail form, then the default assumption is that the form is NOT populated...which would mean that I want the first call to the setup file to be located in the CAPTCHA include file.  BUT, the form processor has to be included outside the ASP blocks, before any of the processing code.  So wouldn't eliminating the include from the processor prevent submitted forms from completing (since the setup file is not included and thus variables aren't declared)?

I'm thinking that if you want the variables to always be declared but only sometimes be referenced by the included CAPTCHA, you'd want to leave the setup include IN the process_form.asp and take it OUT of the CAPTCHA  include; precisely the opposite of what you've done here.  It seems like the way you've got it here, a posted form won't process because the required include is...well, never included.

What am I missing here, other than I could solve my whole issue by just creating a two-page form process instead of trying to stuff it all in one, which is probably a better method of doing things anwyay?Wink


Posted By: Davecl
Date Posted: 19 December 2006 at 3:35pm
mm interesting
 
firstly the easy bit.. we are using a page with the form and processing on the same page because that is how dreamweaver does things and we are assuming that this is the reason why people want to know how to use the captcha on such a pageBig%20smile
 
your main point tho is a bit harder to understand.
 
we need the variables declared, but only once which is why i removed
<!-- #include file="CAPTCHA_setup.asp" --> from the processing file, this include is "included" in the main captcha file which you place in your form and so the variables are declared then. there is no need to declare them again and so once the form is being processed the include is no longer called and everything proceeds as it should.
I haven't tried it the other way round as you suggest because this was the first way i tried and it worked successfully, forms are processed and everything seems to work fine.


Posted By: lowgenius
Date Posted: 19 December 2006 at 3:59pm
I just did it the other way around, and that seems to work too ;-)

Maybe the reason that this is confusing is that on my single-page feedback form, if the user has submitted information in the form, the form does not appear in the confirmation page - feel free to try it out at www.lowgenius.com/contact.asp.  The actual form is in a block of code that is nested inside an 'else' statement - if the form has been submitted and has a value in the required field, then the form never displays...which would make the CAPTCHA include also never display, which means the setup file never fires.

What I did instead was removed the setup include from the captcha file, but not from the processing file.  Since the processing file is read whether a form has been submitted or not (it just never uses the created variables if not) then the variables are always declared, regardless of the post status of the form.

If you'd like, I can post an abridge code sample, but I suspect that you're understanding what i've done without that.


Posted By: bobmac
Date Posted: 19 December 2006 at 5:47pm
Thanks lowgenius...

You say "If you'd like, I can post an abridge code sample, but I suspect that you're understanding what i've done without that."

I'd like to take you up on that.  Big%20smile  I started this thread because I was totally stopped by the name redefine thing. It sounds like you understand this stuff--which I don't Confused--so I any ideas. Davecl was helpful in a PM, but If I see this thing from several angles, there's a slight chance that I might get it!  LOL


-------------
Bob McIntyre


Posted By: Davecl
Date Posted: 20 December 2006 at 6:35am
Originally posted by lowgenius lowgenius wrote:

I just did it the other way around, and that seems to work too ;-)


If you'd like, I can post an abridge code sample, but I suspect that you're understanding what i've done without that.
 
 
yes, I've got i t now LOL and obviuosly you are right, if (like my example) you remove the include from the processing file and then the form is not submitted to that page, then the variables have not been declared, however doing it your way and removing it from the captcha code itself, they are declared cos the processing file declares 'em.
 
So there we have it .. it works either way Big%20smile
Thanks for pointing that out lowgenius, i am confident it will help someone.


Posted By: Davecl
Date Posted: 20 December 2006 at 6:38am
Originally posted by bobmac bobmac wrote:

Thanks lowgenius...

You say "If you'd like, I can post an abridge code sample, but I suspect that you're understanding what i've done without that."

I'd like to take you up on that.  Big%20smile  I started this thread because I was totally stopped by the name redefine thing. It sounds like you understand this stuff--which I don't Confused--so I any ideas. Davecl was helpful in a PM, but If I see this thing from several angles, there's a slight chance that I might get it!  LOL
 
still no luck bob? you never got back to me so i presumed you'd sorted it, maybe lowgenius can help.


Posted By: bobmac
Date Posted: 20 December 2006 at 7:08am
Originally posted by Davecl Davecl wrote:

still no luck bob? you never got back to me so i presumed you'd sorted it, maybe lowgenius can help.


I'm still a bit stuck and VERY short on time. I'm hoping to get some stuff done during the holidays. Did I say holidays???? I thought that meant time off!!! LOL

But I will definitely get back to both you and this great forum on my results!

Thanks to all...and happy holidays, no matter which one you are celebrating...Clap


-------------
Bob McIntyre


Posted By: lowgenius
Date Posted: 20 December 2006 at 11:16am
Sorry about the lag, I'm over here in the colonies, so I just woke up...

As requested, instructions/code for a single-page e-mail form using WWG CATPCHA.  I'm assuming that you have everything installed where it needs to be.

Step 1:  Remove the line <!-- #include file="CAPTCHA_setup.asp" --> from the CAPTCHA_form_inc.asp file

Step 2:  Construct your mail form page as follows (comments are in blue):

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!-- not sure if this works with ASP/JS or not -->
<!-- #include file="CAPTCHA/CAPTCHA_process_form.asp" -->
<!-- doctype, xmlns, head meta tags, whatever here -->

<body>
<!-- page contents, however you have it set up.  Note that the block of code below should appear INSIDE whatever container you want your confirmation message to appear in; this ensures that the message displays in context, rather than at the top of the page before your masthead, menus, etc. as it would if you put the processing code before the html tag -->
                         
<%
If Len(Request.Form("sender")) > 0 then

'checks to see if there's any information in the sender field of the form; this serves as both rudimentary prevention of blank forms and as a yes/no check on whether a form has been submitted; you'll see why that second part is important in a minute


    If blnCAPTCHAcodeCorrect = True Then 'If they get the code right
    'send the message
        'CDONTS code snipped

        Response.write("<h3><i><font color='ffffff'>Your message has been sent to LowGenius Web Design.  We will be in contact with you as soon as possible.  Thank you!</font></h3></i>")
    ElseIf blnCAPTCHAcodeCorrect = False Then ' if they get the code wrong, tell them so
        Response.Write ("<h3><i><font color='ffffff'>You have entered an incorrect code for the CAPTCHA humanity test.  This code help reduce abuse of our contact form by automated systems.  Please use the 'Back' button on your browser to try again.</font></h3></i>")
    End If    'note that this ends the NESTED If; we're still inside another If...Then...Else loop
Else 'If there is no information in the Sender field, assume that the form has not been populated, and display the form
%>

<!-- Insert your form here, and at some point include this, INSIDE THE FORM TAG: -->
<!--#include file="CAPTCHA/CAPTCHA_form_inc.asp" -->
<!-- Continued form code until form and other content you want displayed if there is NO FORM SUBMITTED is ended -->
<% End IF ' and now we break out of the larger if-then-else statement %>
<!--- and the rest of your page code goes here, to be displayed regardless of the form state (submitted or not) -->

The idea here is this: If you load the variables from the setup include at the top of the page, then they're active regardless of whether a form has been submitted or not.  If a form has NOT been submitted, then those variables just remain empty but have been declared so you don't run into problems when the captcha include file tries to define them.  If a form HAS been submitted, then the variables are declared and then populated with your processing code.  It's probably not great practice to have declared variables laying around undefined; if you're a real stickler for detail you can set them to 'nothing' in a code block after the end of your form but BEFORE your final End If; otherwise you'll clear them when the form is submitted and you will end up constantly 'failing' the captcha test.

Please feel free to yank (no pun intended) my chain if you need more clarification; brevity is not my strong suit.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net