#!/usr/planet/bin/perl5 require("include/bbn.pm"); use Msql; #### configuration constants $SENDMAIL = '/usr/lib/sendmail'; # location of your sendmail binary $TO_ADDRESS = 'sourceNEW@mail.cato.com'; # will become this one #### Do standard HTTP stuff #### &cgi_receive; &cgi_decode; &cgi_header; #### Do the actual processing ########################################## #### Make sure the database is alive $dbh = Connect Msql; if (!$dbh) { &do_msql_error; } SelectDB $dbh $DB; #### mash some fields to all lower case $FORM{'email'} = "\L$FORM{'email'}" ; #$FORM{'password'} = "\L$FORM{'password'}" ; #$FORM{'password2'} = "\L$FORM{'password2'}" ; #### Validate the data... are the fields filled in? &check_fields; #&do_pwd_doc; &zorch_nasties; #&check_pwd; &check_logon; #### Add the data to the database $dmade= time(); $query = "insert into $TBL_REG values ('$FORM{'email'}', 'NoMorePwds', '$FORM{'lname'}', '$FORM{'fname'}', '$FORM{'company'}', '$FORM{'title'}', '$FORM{'address'}', '$FORM{'country'}', '$FORM{'phone'}', '$FORM{'fax'}', '$FORM{'howheard'}', $dmade, '$ENV{'REMOTE_ADDR'}', '$ENV{'REMOTE_HOST'}', '$ENV{'REMOTE_USER'}', 'N',$dmade)"; $sth = Query $dbh $query; if (!defined($sth)) { print "We were unable to add your information to the CatoSource database."; print "

\n"; print "Please try registering again in a few minutes, or contact "; print "CatoSource to report the problem using the email address below."; print "

\n"; &cgi_footer; exit; } #### snapshot the database for backup $DBDUMPFILE = $DBDUMP_PATH . $DB . ".dump." . $dmade ; `$DBDUMPER $DB >$DBDUMPFILE` ; #### confirm data with the user &do_thanks_doc; #### Notify someone at CCS &do_mail; exit; #### SUBROUTINES #################################################### sub error_blank_field { # Procedure to send a message back to the user if a required field on # the form was left blank. Call with the name of the missing field. local($variable) = @_; print "

Incomplete Form

\n"; print "You did not fill in $variable.\n"; print "Please provide all the requested information.\n"; print "Use your browser's Back operation to return to the form;"; print "any existing information will be retained. \n"; &cgi_footer; exit; } sub check_fields { # Check all the required fields for a form and fail if any are blank # ouputs a apropos error message first &error_blank_field('your last name') unless ($FORM{'lname'}); &error_blank_field('your first name') unless ($FORM{'fname'}); &error_blank_field('your company') unless ($FORM{'company'}); &error_blank_field('your address') unless ($FORM{'address'}); &error_blank_field('your country') unless ($FORM{'country'}); &error_blank_field('your phone number') unless ($FORM{'phone'}); &error_blank_field('your email address') unless ($FORM{'email'}); } sub zorch_nasties { # Check form fields for characters that will foul up the database insertion # first replace ' char by \' $FORM{'email'} =~ s/'/\\'/g ; #$FORM{'password'} =~ s/'/\\'/g ; #$FORM{'password2'} =~ s/'/\\'/g ; $FORM{'lname'} =~ s/'/\\'/g ; $FORM{'fname'} =~ s/'/\\'/g ; $FORM{'company'} =~ s/'/\\'/g ; $FORM{'address'} =~ s/'/\\'/g ; $FORM{'country'} =~ s/'/\\'/g ; $FORM{'phone'} =~ s/'/\\'/g ; $FORM{'fax'} =~ s/'/\\'/g ; $FORM{'title'} =~ s/'/\\'/g ; $FORM{'howheard'} =~ s/'/\\'/g ; } sub do_thanks_doc { print<Thank You for Registering

Next time you use CatoSource enter as a registered reader.

The following information has been recorded for you: