Why isn't the captcha working in this asp page?

Posted on 2012-08-28
Last Modified: 2012-08-30
I have a page here:

that I've inserted code for captcha I found here:

but for some reason it does not work.

I've included the reserve.asp code.

Any help would be appreciated.
Question by:Donnie Walker
    LVL 52

    Assisted Solution

    by:Scott Fell, EE MVE
    You have to have the code on both the form page and response page
    LVL 49

    Accepted Solution

    You don't appear to be any form validation on the server side - clicking ok on the empty form submits the form and gives you a thank you page.

    You will need to add some server code that checks your form variables to ensure they are valid for the fields they are entered for.

    This applies to the captcha as well.

    Take a look at this code snippt from the ZIP you downloaded. You need to implement something similar in your code.
            if Request.ServerVariables("REQUEST_METHOD") = "POST" and IsEmpty(Request.Form("btnRetry")) then
                Dim lblResult, lblColor
                if IsEmpty(Session("ASPCAPTCHA")) or Trim(Session("ASPCAPTCHA")) = "" then
                    lblResult = "This test has expired."
                    lblColor = "red"
                    Dim TestValue : TestValue = Trim(Request.Form("txtCaptcha"))
                    '//Uppercase fix for turkish charset//
                    TestValue = Replace(TestValue, "i", "I", 1, -1, 1)
                    TestValue = Replace(TestValue, "I", "I", 1, -1, 1)
                    TestValue = Replace(TestValue, "i", "I", 1, -1, 1)
                    TestValue = UCase(TestValue)
                    if StrComp(TestValue, Trim(Session("ASPCAPTCHA")), 1) = 0 then
                        lblResult = "CAPTCHA PASSED"
                        lblColor = "green"
                        lblResult = "CAPTCHA FAILED"
                        lblColor = "red"
                    end if
                    '//IMPORTANT: You must remove session value for security after the CAPTCHA test//
                    Session("ASPCAPTCHA") = vbNullString
                end if

    Open in new window

    LVL 52

    Expert Comment

    by:Scott Fell, EE MVE
    The sample code is for the form and response on the same page. You  are posting to a cfm page.  I answered your original question that was deleted for the same thing. You would be better off going back to the reCaptcha example and using the client side javascript version to use both asp and cfm.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Article by: DanRollins
    This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (, we'll extend the program by adding a depth-…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now