#!/usr/bin/perl # joinclub.cgi--Perl script for # sending email to the manager use CGI qw(:standard); ## cgi perl module var $err_msg = "", $club="cs.kent.edu"; var $subject = "Subject: New Member club.com"; ###var $to="To: manager\@$club"; var $to="To: pwang\@$club"; var $mailprog = '/usr/lib/sendmail -t'; var $name = param('name'); ## form data var $email = param('email'); ## form data var $xhtml_front = ' '; if ( ! $name ) ## $name is empty { $err_msg .= "

Name must be specified.

"; } if ( ! $email ) ## $email is empty { $err_msg .= "

Email must be specified.

"; } if ( $err_msg ) { &error(); ## function call exit; ## terminate program } ## mail notice to manager open(MAIL, "| $mailprog "); print MAIL "$to\n"; print MAIL "$subject\n"; print MAIL "\n"; ## mail header ends print MAIL "Name: $name\n"; ## mail body begin print MAIL "Email: $email\n"; print MAIL "to join $club"; close(MAIL); ## Send response to standard output print "Content-type: text/html\r\n\r\n"; print <Thanks for Joining

Thank you $name.

Welcome to club.com. Your membership will be processed shortly.

We will email you at $email about your new membership at $club.

END ####################################### sub error() { print "Content-type: text/html\r\n\r\n"; print "$xhtml_front\r\n"; print 'Error'; print ''; print '

Data Missing

'; print "

$err_msg Please go BACK, make corrections, "; print 'and submit the form again.

'; }