#!/usr/local/bin/perl ############################################################################## # # FORMS PROCESSING # ############################################################################## # CONFIGURATION DATA # $contact_form_name = "contact_us_rendered.html"; $thanks_page_name = "contact_us_thanks_rendered.html"; #$mail_from_address = "form_submission\@castlecareconcrete.com"; #$mail_to_address = "jennifer\@nu-designs.com"; $mail_from_address = "castlecare\@castlecareconcrete.com"; $mail_to_address = "castlecare\@castlecareconcrete.com"; $mail_subject = "Comments from your Website"; ############################################################################## # Support files needed require "contact_us-cgi-lib.pl"; require "contact_us-mail-lib.pl"; print "Content-type: text/html\n\n"; &ReadParse; $page = $in{"action"}; $first_name= $in{"first_name"}; $last_name = $in{"last_name"}; $company = $in{"company"}; $address = $in{"address"}; $city = $in{"city"}; $state = $in{"state"}; $zip = $in{"zip"}; $country = $in{"country"}; $phone = $in{"phone"}; $fax = $in{"fax"}; $email = $in{"email"}; $comments = $in{"comments"}; $how_found = $in{"how_found"}; $contact_email = $in{"contact_email"}; $contact_phone = $in{"contact_phone"}; $contact_fax = $in{"contact_fax"}; $contact_mail = $in{"contact_mail"}; $contact_none = $in{"contact_none"}; if ( $contact_email eq "1" ) { $contact_email_checked = "checked"; } else { $contact_email_checked = ""; } if ( $contact_phone eq "1" ) { $contact_phone_checked = "checked"; } else { $contact_phone_checked = ""; } if ( $contact_fax eq "1" ) { $contact_fax_checked = "checked"; } else { $contact_fax_checked = ""; } if ( $contact_mail eq "1" ) { $contact_mail_checked = "checked"; } else { $contact_mail_checked = ""; } if ( $contact_none eq "1" ) { $contact_none_checked = "checked"; } else { $contact_none_checked = ""; } ############################################################################## # page = null if ($page eq "") { open (PAGE, "$contact_form_name"); while () { s/%%message%%//g; s/%%page%%/submit/g; s/%%name%%//g; s/%%email%%//g; s/%%value_first_name%%//g; s/%%value_last_name%%//g; s/%%value_company%%//g; s/%%value_address%%//g; s/%%value_city%%//g; s/%%value_state%%//g; s/%%value_zip%%//g; s/%%value_country%%//g; s/%%value_phone%%//g; s/%%value_fax%%//g; s/%%value_email%%//g; s/%%value_comments%%//g; s/%%value_how_found%%//g; s/%%contact_email_checked%%//g; s/%%contact_phone_checked%%//g; s/%%contact_fax_checked%%//g; s/%%contact_mail_checked%%//g; s/%%contact_none_checked%%//g; s/%%message1%%//g; s/%%message2%%//g; s/%%message3%%//g; s/%%message4%%//g; s/%%message5%%//g; s/%%message6%%//g; s/%%message7%%//g; s/%%message8%%//g; print $_; } # end while } # end if ############################################################################## # page = submit if (($page eq "- Send Message -")) { $error=false; ## check for errors so we know what to process ## then check again as we process the form re-display if ($comments eq "") { $error=true;} if ( ($contact_email eq "") && ($contact_phone eq "") && ($contact_mail eq "") && ($contact_none eq "") ) { $error=true;} #if ( ($contact_phone eq "") && ($phone eq "") ) {$error=true;} #if ( ($contact_email eq "") && ($email eq "") ) {$error=true;} #if ( ($contact_mail eq "") && ( ($address eq "") || # ($city eq "") || ($state eq "") || ($zip eq "") || # ($country eq "") ) ) {$error=true;} if ( ($first_name eq "") || ($last_name eq "")) {$error=true;} if ( $comments eq "" ) {$error=true;} if ( $error eq true ) { open (PAGE, "$contact_form_name"); while () { s/%%value_first_name%%/$first_name/g; s/%%value_last_name%%/$last_name/g; s/%%value_company%%/$company/g; s/%%value_address%%/$address/g; s/%%value_city%%/$city/g; s/%%value_state%%/$state/g; s/%%value_zip%%/$zip/g; s/%%value_country%%/$country/g; s/%%value_phone%%/$phone/g; s/%%value_fax%%/$fax/g; s/%%value_email%%/$email/g; s/%%value_comments%%/$comments/g; s/%%value_how_found%%/$how_found/g; s/%%contact_email_checked%%/$contact_email_checked/g; s/%%contact_phone_checked%%/$contact_phone_checked/g; s/%%contact_fax_checked%%/$contact_fax_checked/g; s/%%contact_mail_checked%%/$contact_mail_checked/g; s/%%contact_none_checked%%/$contact_none_checked/g; s/%%message1%%/Fields marked with a '*' are required.
/g; if ($comments eq "") { $error=true; s/%%message2%%/Please let us know how we may help you.
/g; } else { s/%%message2%%//g; } # end if #if ( ($contact_email eq "") && ($contact_phone eq "") && # ($contact_fax eq "") && ($contact_mail eq "") && # ($contact_none eq "") ) { # $error=true; # s/%%message3%%/Please let us know how we may contact you.
/g; #} else { s/%%message3%%//g; #} #if ( ($contact_phone eq "") && ($phone eq "") ) { # $error=true; # s/%%message4%%/Please provide your phone number.
/g; #} else { s/%%message4%%//g; #} #if ( ($contact_email eq "") && ($email eq "") ) { # $error=true; # s/%%message5%%/Please provide your email address.
/g; #} else { s/%%message5%%//g; #} s/%%message6%%//g; #if ( ($contact_mail eq "") && ( ($address eq "") || # ($city eq "") || ($state eq "") || ($zip eq "") || # ($country eq "") ) ) { # $error=true; # s/%%message7%%/Please provide your mailing address.
/g; #} else { s/%%message7%%//g; #} if ( ($first_name eq "") || ($last_name eq "")) { $error=true; s/%%message8%%/Please specify your first and last name.
/g; } else { s/%%message8%%//g; } # end if ## print the line after we processed it print $_; } # end while } if ( $error eq false ) { # build the response row $message = "\n\n-=-=-=-=-=-=-=- Automated Message -=-=-=-=-=-=-=-\n\n"; $message .= "Comments:\n $comments\n\n"; if ( $contact_phone eq "1" ) { $message .= "Followup Method: Phone\n"; } if ( $contact_fax eq "1" ) { $message .= "Followup Method: Fax\n"; } if ( $contact_email eq "1" ) { $message .= "Followup Method: Email\n"; } if ( $contact_mail eq "1" ) { $message .= "Followup Method: Postal Mail\n"; } if ( $contact_none eq "1" ) { $message .= "Followup Method: Don't Contact\n"; } $message .= "\n"; $message .= "$first_name $last_name "; if ( $email ne "" ) { $message .= "($email)"; } $message .= "\n"; if ( $company ne "" ) { $message .= "$company\n"; } if ( $address ne "" ) { $message .= "$address\n"; } if ( $city ne "" || $state ne "" || $zip ne "" ) { $message .= "$city, $state $zip\n"; } if ( $country ne "" ) { $message .= "$country\n"; } $message .= "\n"; if ( $phone ne "" ) { $message .= "$phone (Phone)\n"; } if ( $fax ne "" ) { $message .= "$fax (Fax)\n"; } $message .= "\n"; if ( $how_found != "" ) { $message .= "How Found Website:\n $how_found\n\n"; } $message .= "\n\n-=-=-=-=-=-=-=- Automated Message -=-=-=-=-=-=-=-\n\n"; open (PAGE, "$thanks_page_name"); while () { print $_; } &send_mail($mail_from_address, $mail_to_address, $mail_subject, "$message"); } # end if not error } # end if ############################################################################## exit;