| Author |
Topic Search Topic Options
|
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
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.
|
 |
Davecl
Newbie
Joined: 22 November 2006
Location: United Kingdom
Status: Offline
Points: 10
|
Post Options
Thanks(0)
Quote Reply
Posted: 22 November 2006 at 3:02pm |
done it
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'** |
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
and now you can  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 
Edited by -boRg- - 19 December 2006 at 9:03am
|
 |
bobmac
Newbie
Joined: 18 November 2006
Status: Offline
Points: 5
|
Post Options
Thanks(0)
Quote Reply
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...
Edited by bobmac - 28 November 2006 at 6:59am
|
 |
Davecl
Newbie
Joined: 22 November 2006
Location: United Kingdom
Status: Offline
Points: 10
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
lowgenius
Newbie
Joined: 02 August 2004
Status: Offline
Points: 20
|
Post Options
Thanks(0)
Quote Reply
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?
Edited by lowgenius - 19 December 2006 at 1:59pm
|
 |
Davecl
Newbie
Joined: 22 November 2006
Location: United Kingdom
Status: Offline
Points: 10
|
Post Options
Thanks(0)
Quote Reply
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 page 
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.
Edited by Davecl - 19 December 2006 at 3:35pm
|
 |
lowgenius
Newbie
Joined: 02 August 2004
Status: Offline
Points: 20
|
Post Options
Thanks(0)
Quote Reply
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.
|
 |
bobmac
Newbie
Joined: 18 November 2006
Status: Offline
Points: 5
|
Post Options
Thanks(0)
Quote Reply
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.  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  --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!
|
 |