Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How do I make a form field required for a Perl Chat Script?

by Popcorn Dave (Abbot)
on Feb 22, 2008 at 17:50 UTC ( #669617=note: print w/replies, xml ) Need Help??


in reply to How do I make a form field required for a Perl Chat Script?

The generic answer is that there are at least two ways to do what you're attempting. One is to use JavaScript to check that all fields that you require are filled in and not let the page proceed until that requirement is met.

The purely Perl option is to use self referencing CGI, similar to what olus said to do your parsing and not let the script move on until your conditions are met.

$|++; use strict; use CGI; my $query = CGI->new(); print $query->header; if ( !$query->param() ) { # no parameters so display your login page my_login_form(); } else { #since you've got parameters, make sure all that you require are fil +led in and process accordingly.

If your not getting all the fields filled in you want, you just redisplay the login form. If you do get all your fields filled in and verified, then you can proceed.

HTH!


Revolution. Today, 3 O'Clock. Meet behind the monkey bars.

I would love to change the world, but they won't give me the source code

Replies are listed 'Best First'.
Re^2: How do I make a form field required for a Perl Chat Script?
by Your Mother (Bishop) on Feb 22, 2008 at 22:40 UTC
    The generic answer is that there are at least two ways to do what you're attempting. One is to use JavaScript to check that all fields that you require are filled in and not let the page proceed until that requirement is met.

    I think there are two ways you are required to do it in that case. Client-side stuff is great for user experience and helping to keep load off the server but it's completely useless for validating things in the end because they can be sent by a hacker or "broken" browser anyway. Verify and block bad submissions in the client if you can but remember you should do the same thing on the server side either way.

      You're right, but I thought the OP was asking how to make sure that a field was filled in before progressing. I may have misread the OP's intent.


      Revolution. Today, 3 O'Clock. Meet behind the monkey bars.

      I would love to change the world, but they won't give me the source code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://669617]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2019-04-21 04:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (110 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!