--- "AMORE,JUAN (HP-Roseville,ex1)" <[EMAIL PROTECTED]> wrote: > > Hello Prel Gurus, > I've learned more as time go's on, especially with all your HELP:) > My last attempt has been somewhat difficult. > Can anyone advise regarding CGI perl scripts. > I need to inject a if elsif else statement in the below code so that if any > one of > my HTML form fields is empty for it to print a simple HTML error message > until all fields are loaded with data.. > I've tried Perl Monks for some wisdom but they couldn't give me a start on > the right direction:(
Really? I am Ovid on Perlmonks and I can't help but wonder if you missed my reply to your post (http://www.perlmonks.org/index.pl?node_id=128475): #!/usr/bin/perl -wT use strict; use CGI qw/:standard/; my %errors; my ( $candidate ) = ( param( 'candidate' ) =~ /^([\s\w]+)$/ ); # candidate must be defined and have at least one non-whitespace character if ( ! defined $candidate or $candidate !~ /\S/ ) { $errors{ candidate } = 'You must supply a value for candidate'; } # grab more params and untaint if ( %errors ) { display_page_with_errors( \%errors ); } If that is not a start in the right direction, I am rather curious as to your definitions of "start" and "right direction". What I think you really are asking is "How do I create a 'sticky' HTML page". 'sticky', in this context, means that if a user is sent back to the same page, any values that they already filled in are still there. Now, I perfectly realize that you might not understand the code I wrote. That's fine. What part do you not understand? I (or many of the other monks) would be happy to explain it to you. When you ask how to make the present an error message, there is no way to give you a "correct" answer because it is impossible to know, from your snippet, how you are generating your HTML. HTML and Perl are not the same thing and, as a result, you have to determine how you want to pass information to the HTML form. Are you using multiple print statements? Are you using HERE documents? Perhaps you're using Template::Toolkit, HTML::Mason or HTML::Template. There are plenty of ways to generate the HTML and until we have a clearer idea of how you do this, telling you how to generate an error message that fits with how you generate HTML is just a wild guess. Here's one way to do it, not using any of the methods listed above, but relying on the %error hash in my snippet being populated and using CGI/:standard/: # untested code if ( %errors ) { print header, start_html( -title => 'Form Errors' ), h1( 'Your form was not filled out completely.' ); foreach my $message ( values %errors ) { print p( $message ); } print p( 'Please hit the back button on your browser and complete the form.' ), end_html; } else { # process data } If you are not familiar with CGI.pm's HTML generating functions, the above code is probably a bit confusing. Don't worry about that. If you don't understand it, just ask. I really have no way to assess what you really intend from the question you asked. If this works, great. If it doesn't, ask and I or someone else will be happy to provide more information. Cheers, Curtis "Ovid" Poe ===== Senior Programmer Onsite! Technology (http://www.onsitetech.com/) "Ovid" on http://www.perlmonks.org/ __________________________________________________ Do You Yahoo!? Buy the perfect holiday gifts at Yahoo! Shopping. http://shopping.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]