Tom Castonzo wrote: > Hello All, > > I am trying to error check some form fields using CGI PM > Can someone tell me what I am doing wrong here: > > #Call the error checking subroutine > &errorCheck($q->param("email")); > > Thanks, > Tom Castonzo ["Well *that* is a question quite clear" said Tommy with such sarcasm it surprised even himself.] # real men and smart ladies... use strict; use CGI qw( :param ); my($cgi) = CGI->new(); # validate input &validate_params(qw(company web_domain phone addr city state zip country)); # subroutine which handles validation sub validate_params { my($error) = ''; my($bullet) = '·'; my(@required) = (); my(@required_arguments) = @_; my(@required_defaults) = qw( email fname lname ); @required = (@required_arguments,@required_defaults); foreach (@required) { my($req) = $_; # avoid uninit variable warnings my($val) = $cgi->param($req)||''; if (length($val) == 0) { $error .= qq[\n
$bullet $req
\n]; } } if (length($error) > 0) { &error(<<__error__);

The following required fields were left blank in the form.

$error

Please go back and fill them out in order to proceed to the next step in the registration process.

Thank you.

__error__ } return(1); } # subroutine which handles bad input sub error { my($error) = ((join('',@_))||'[unspecified error]'); my($errtext) = <<'__error__'; q[ Error

Error

An error has occurred.

].$error.q[
]; __error__ print($cgi->header()); print(eval($errtext)); exit; } __END__
-- -Tommy Butler http://atrixnet.com I'm looking for work! contract or perm, full or part time Download my résumé http://www.atrixnet.com/resume the Open Source Perl Archives at Atrixnet. http://www.atrixnet.com/pub/