Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi Monks,

Although I am grateful to still have hair remaining, I am pulling it out over an ostensibly simple CGI program I am trying to modify.

The interface keeps getting hit by bots and this results in cleanup time for yours truly -- so I was asked to put a simple CAPTCHA-type interface on this ca. 2000 or so CGI page.

I'm using the Authen::Captcha module to do this.

When the user is facing the front page s/he is asked to pick from a series of radio buttons - this is collected in a parameter 'CategoryRequest'. If this param is set, the program goes off and creates a new captcha object, then sends the user off to a page where this is displayed and a response is requested. Here's the code for that part, since it's the part causing me the headache:

sub getUserEntry { print header( "text/html" ), start_html( "User Validation" ), $header, h3( "Entry Validation" ), start_form, hr, p("Please enter the characters in the image at the bottom of t +he page"), textfield( -name => "UserEntry", -size => 15 ), br, br, submit( -name => "CodeValidation", -value => " Enter the Code " ), br, br, hr; print end_form; print "\<img src=\"./$www_output_dir/$md5sum.png\"\>"; print $footer; print end_html; return; }

... I'm expecting that sub to return to where I came from with the 'UserEntry' param filled in, so I can first validate the response and then make decisions based on the result ...

... but instead of waiting for the submit button to be pressed and the parameter to be duly defined, the program just swoops over or through the subroutine (whether I return things explicitly from it or not), assumes param( 'UserEntry' ) is empty, and displays both the UserEntry page along with an error page ("You haven't entered anything!") underneath it together in the same lump of html.

Why does this 'fall-through' happen? The logic I'm employing is as follows:

If the param( 'CategoryRequest' ) exists: create the captcha; get the user's response; If the user's response exists: <-- but this is never true check it against the real answer; do other things based on results of check

How do I get the UserEntry section to 'wait' for the user to enter something?

This feels like a far more basic question than I should have to be asking at this point in my learning, but ... here it is.

Thanks,

Glenn


In reply to CGI form 'falls through' without capturing anything by chexmix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-25 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found