in reply to Re: Why use HTML instead of CGI? (codediscussion)
in thread Why use HTML instead of CGI? (code, discussion)
#!/usr/bin/perl # silly.pl # http://smb.yso.net/cgi-bin/silly.pl use CGI::ParamError qw(:standard :html3); my $q = new CGI::ParamError; # REQUIRED FIELDS # first_name last_name email print header(); unless (param()){ display_form(); }else{ unless (param('first_name')=~/\w/){ param_error('first_name',"Sorry, I need to know your first nam +e"); } unless (param('last_name')=~/\w/){ param_error('last_name',"Sorry, I need to know your last name" +); } unless (param('email')=~/^\w+\@\w+\.\w/){ param_error('email',"Sorry, param('email') doesn't seem like a + valid email"); } if ($q->has_errors){ display_form(); }else{ # DO SOMETHING HERE confirmation(); } } ######################################### sub display_form{ # show_error_messages() is part of my module, this is where the ve +rbose messages are displayed # Should be called AFTER fields are validated. print start_html(-title=>'Silly Script'), show_error_message(), start_form, "First Name",textfield(-name=>'first_name'),br, "Last Name",textfield(-name=>'last_name'),br, "Your Email",textfield(-name=>'email'),br, submit,br, end_form, end_html; } ######################################### sub confirmation{ print start_html(-title=>'Silly Script'), "Thanks for stopping by ",param('first_name')," ",param('last_ +name'),"!"; end_html; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Slightly OT
by Tuna (Friar) on May 14, 2001 at 15:58 UTC | |
by shotgunefx (Parson) on May 15, 2001 at 12:16 UTC |