"Jason Gray" <[EMAIL PROTECTED]> wrote in message news:...
> Could I do this?
>
> sub check_fields {
> my $q = shift;
> my $match;
> my @fields = ('name', 'email', 'city', 'state', 'message');
> foreach my $field (@fields) {
> next if ($q->param($field));
> $match = 0;
> print "Please fill in your " . ucfirst($field) . ".\n";
> exit;
> }
> $match = 1;
> }
>
>
> "Jason Gray" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > #!/usr/bin/perl -w
> >
> > use strict;
> > use warnings;
> >
> > use CGI();
> > use Mail::Mailer;
> >
> > my $q = CGI->new();
> >
> > print $q->header();
> >
> > #-----------------------------------------
> > # * startup methods -> global variables.
> >
> > check_fields();
> >
> > #-----------------------------------------
> >
> > sub check_fields {
> > my $blanks;
> > my @fields = qw(name email city state message);
> > foreach my $field (@fields) {
> > $blanks++ if !$q->param($field);
> > }
> > if($blanks) {
> > print qq(Error: There were some blank fields.);
> > exit;
> > }
> > unless($q->param('email') =~ /[EMAIL PROTECTED]/) {
> > print qq(Error: Please enter a valid email address.);
> > }
> > send_email();
> > }
> >
> >
> > sub send_email {
> > my $m = Mail::Mailer->new('sendmail');
> > $m->open({ From => $q->param('email'),
> > To => 'perl <[EMAIL PROTECTED]>',
> > Subject => '[INFO] Site Comment',
> > }) or die $!;
> > print $m "Name: " . ucfirst($q->param('name')) . "\n";
> > print $m "Location: " . ucfirst($q->param('city')) . ", " .
> > $q->param('state') . "\n\n";
> > print $m $q->param('message');
> > $m->close();
> > print qq(Thank you for emailing us. We will contact you in the next 24
> > hours.);
> > }
> >
> >
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>