einerwitzen has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl $mailprog = "/usr/lib/sendmail"; $msg = ""; $send_to = "webmaster\@3dwc.com"; $subject = "Online Repair Status Inquiry"; $from = "Form Submission"; $ok_url = "/thanks.html"; $bad_url = "/nogo.html"; %f = &parseform; foreach $key (sort keys %f) { $mystring = "$key: $f{$key}\n"; $msg .= $mystring; } &sendmail($from,$send_to,$subject,$msg); print "Location: $ok_url\n\n"; sub sendmail { my($from,$to,$subject,@msg) = @_; open(MAIL,"|$mailprog -t"); print MAIL "To: $to\n"; print MAIL "From: $from\n"; print MAIL "Subject: $subject\n\n"; print MAIL <<EndMail; @msg EndMail close(MAIL); } sub parseform { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; if ($name = "firstname"){ if ($value = ""){ die print "must enter first name"; }else{ #all is well } }elsif ($name = "lastname{ #all is well } } return %FORM; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: modification of simple form-email script
by gellyfish (Monsignor) on Mar 06, 2002 at 21:17 UTC | |
|
Re: modification of simple form-email script
by perrin (Chancellor) on Mar 06, 2002 at 22:04 UTC | |
|
Re: modification of simple form-email script
by silent11 (Vicar) on Mar 06, 2002 at 21:15 UTC | |
|
Re: modification of simple form-email script
by trs80 (Priest) on Mar 06, 2002 at 21:23 UTC | |
|
Re: modification of simple form-email script
by einerwitzen (Sexton) on Mar 06, 2002 at 21:11 UTC |