BigJoe has asked for the wisdom of the Perl Monks concerning the following question:
I really think it is an Apache issue. Has anyone else had this? Thanks#!/usr/bin/perl # Setting up my include files use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use Net::SMTP; undef $/; # Creating objects my $q = ""; $q = new CGI; my $email_body = ""; my @params = $q->param; my %param = {}; my %product_names = ( 'product_a' => 'Product A', 'product_b' => 'Product B'); foreach (@params) { $param{$_} = 1; } $email_body.="calling HANDLE_PERSONAL_INFORMATION\n"; HANDLE_PERSONAL_INFORMATION(); $email_body.="calling HANDLE_PRODUCTS\n"; HANDLE_PRODUCTS(); PRINT_HEADER(); SEND_EMAIL($email_body); #print $email_body; exit; sub HANDLE_PRODUCTS { #this is where I will do all the product handling my @last_params = keys %param; $email_body.="Listing products selected:\n"; foreach (@last_params) { $email_body .= $product_names{$_} . "($_): " . $q->param($_) . "\n +" if($q->param($_) != 0); } } sub HANDLE_PERSONAL_INFORMATION { my $order_num = $_[0]; my @personal_information = ('name', 'street', 'city', 'state', 'zi +p', 'phone', 'email'); my @errors = HANDLE_INFORMATION(@personal_information); if(($errors[0] != 0) || ($#errors > 1)){ # I have created an error please help PRINT_HEADER(); HANDLE_ERRORS(@errors); PRINT_FOOTER(); exit; } } sub HANDLE_INFORMATION { my @columns = @_; $email_body.="Inside HANDLE_INFORMATION with columns: @columns\n"; my @errors = (); foreach (@columns){ my $temp = $q->param("$_"); if($temp ne ''){ delete($param{$_}); $email_body .= uc $_; $email_body .= ": $temp\n"; } else { #debuging push @errors, $_; } } if($#errors == 0){ return 0; } else { return @errors; } } sub HANDLE_ERRORS { ####################################### # This handles all the errors that # # the user causes # ####################################### foreach (@_){ my $temp = ucfirst($_); print "<font color=red>$temp is required</font><br>\n"; } print "Please hit the back button and fill out all the fields\n"; } sub PRINT_HEADER { print $q->header; print <<EODUMP; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>PAGE TITLE</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +"> </head> <body bgcolor="#FFFFFF" text="#000000"> HEADER GOES HERE EODUMP } sub PRINT_FOOTER { print <<EODUMP; </td> </tr> </table> </td> </tr> </table> </body> </html> EODUMP } sub SEND_EMAIL { my $smtp = Net::SMTP->new("my.email.server") or HANDLE_ERROR("Can +not submit. System Down."); $smtp->mail ('email@domain'); $smtp->to ('email@domain'); $smtp->data(); $smtp->datasend("To: email\@domain\n"); $smtp->datasend("From: email\@domain\n"); $smtp->datasend("Subject: Order\n"); $smtp->datasend("\n"); $smtp->datasend($email_body); $smtp->dataend(); $smtp->quit; print "Your order has been submitted.<br>\n"; print "You should be contacted shortly<br>\n"; my @array = split(/\n/, $email_body); foreach(@array){ print "$_<br>"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI or Apache Problem?
by dws (Chancellor) on Jan 19, 2002 at 03:16 UTC | |
by BigJoe (Curate) on Jan 19, 2002 at 08:35 UTC | |
|
Re: CGI or Apache Problem?
by perrin (Chancellor) on Jan 19, 2002 at 03:00 UTC | |
by BigJoe (Curate) on Jan 19, 2002 at 08:25 UTC | |
by perrin (Chancellor) on Jan 19, 2002 at 09:20 UTC | |
|
Re: CGI or Apache Problem?
by tune (Curate) on Jan 19, 2002 at 02:44 UTC |