Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 500

Status
Not open for further replies.

dreams3577

Programmer
Jun 2, 2002
4
US
Hi all
have this script, it is the last in a three part shopping script, below is the script order,

1) input vales through form (ie name, address, card details) (orderform.htm)
2)Select Quantities (order01.cgi)
3)Order Confirmation (order02.cgi)
4)sendmail and echo reply (order03.cgi)(this script)

i am having problems with step 4 (order03.cgi), the variables are being passed and the script is sending all the correct emails out and user is recieving them ok, but the browser returns a Error 500 Internal Server Error message
thanks for any help
steve

_______________________________________________________
#!/usr/local/bin/perl

## ---------------------------------------------------------------------------------------
## This is the final processing file.
## This file processes the order information into a log file (order_log.dat)
## And then the order information by email to Merchant and Customer if enabled
## =======================================================================================

# Call the configuration file using the require command
require 'order00.cfg';

## Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

## Split the name-value pairs
@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;
$value =~ s/<([^>]|\n)*>//g;
$value =~ s/<//g;
$value =~ s/>//g;
$FORM{$name} = $value;
}

### Get the Date
@months = ('January','February','March','April','May','June','July','August','September','October','November','December');
@days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
($mday,$mon,$year,$wday) = (localtime(time))[3,4,5,6];
$year += 1900;
$date = &quot;$days[$wday], $months[$mon] $mday, $year&quot;;

## Get the new invoice number
unless (open (NUMBER, &quot;$number_path&quot;)) {
print &quot;Content-type: text/html\n\n&quot;;
print &quot;<html><head><title>File Processing Error !</title></head>\n&quot;;
print &quot;<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF ALINK=#0000FF VLINK=#0000FF>\n&quot;;
print &quot;<center>\n<table border=0 cellpadding=2 cellspacing=0 width=500>\n&quot;;
print &quot;<tr><td><font face=\&quot;Arial,Helvetica\&quot; size=4><strong>&quot;;
print &quot;<font size= 5 color=blue><a href=\&quot;$base_url$main_filename\&quot;>&quot;;
print &quot;<i>$site_name </i></a></strong>&quot;;
print &quot;file processing error !</td></tr>&quot;;
print &quot;<tr><td><font face=\&quot;Arial,Helvetica\&quot; size=2 color=black>&quot;;
print &quot;There has been an essential file error attempting to open the invoice data file on the server.&quot;;
print &quot;<ul><li><strong>$number_path</strong></ul></td></tr> &quot;;
print &quot;<tr><td> </td></tr>&quot;;
print &quot;<tr><td><font face=\&quot;Arial,Helvetica\&quot; size=2 color=black>&quot;;
print &quot;<strong>No billing information has been processed at this point.</strong></td></tr>&quot;;
print &quot;<tr><td> </td></tr>&quot;;
print &quot;<tr><td><font face=\&quot;Arial,Helvetica\&quot; size=2 color=red>$date</td></tr>&quot;;
print &quot;<tr><td>Please notify the merchant of this error <a href=\&quot;mailto:$recipient\&quot;>$recipient</a></td></tr>&quot;;
print &quot;</table>&quot;;

print &quot;<table border=0 cellpadding=2 cellspacing=0 width=570>&quot;;
print &quot;<tr><td><hr size=0></td></tr>&quot;;
print &quot;<tr><td> </td></tr><tr><td><Center><font size=2 face=arial>&quot;;
print &quot;Copyright © $year -- &quot;;
print &quot;<A href=\&quot;$site_location\&quot;>$site_name</A> -- &quot;;
print &quot;All Rights Reserved.&quot;;
print &quot;</font></Center></td></tr>&quot;;
print &quot;</table>&quot;;

print &quot;</center>&quot;;
print &quot;</body></html>&quot;;
die
}

$num = <NUMBER>;
close (NUMBER);
$num++;

## Reset the invoice number
unless (open (NUMBER, &quot;>$number_path&quot;)) {
print &quot;Content-type: text/html\n\n&quot;;
print &quot;<html><head><title>File Processing Error !</title></head>&quot;;
print &quot;<body>&quot;;
print &quot;<center><table border=0 cellpadding=2 cellspacing=0 width=500>&quot;;
print &quot;<tr><td><font face=\&quot;Arial,Helvetica\&quot; size=4><b>&quot;;
print &quot;<font size= 5 color=blue><a href=\&quot;$base_url$main_filename\&quot;>&quot;;
print &quot;<i>$site_name </i></a></b>&quot;;
print &quot;file processing error !</td></tr>&quot;;
print &quot;<tr><td><font face=\&quot;Arial,Helvetica\&quot; size=2 color=black>&quot;;
print &quot;There has been an essential file error attempting to open the invoice data file on the server.&quot;;
print &quot;<ul><li><strong>$number_path</strong></ul></td></tr> &quot;;
print &quot;<tr><td> </td></tr>&quot;;
print &quot;<tr><td><font face=\&quot;Arial,Helvetica\&quot; size=2 color=black>&quot;;
print &quot;<strong>No billing information has been processed at this point.</strong></td></tr>&quot;;
print &quot;<tr><td> </td></tr>&quot;;
print &quot;<tr><td><font face=\&quot;Arial,Helvetica\&quot; size=2 color=red>$date</td></tr>&quot;;
print &quot;<tr><td>Please notify the merchant of this error <a href=\&quot;mailto:$recipient\&quot;>$recipient</a></td></tr></table>&quot;;
print &quot;<table border=0 cellpadding=2 cellspacing=0 width=570>&quot;;
print &quot;<tr><td><hr size=0></td></tr>&quot;;
print &quot;<tr><td> </td></tr><tr><td><Center><font size=2 face=arial>&quot;;
print &quot;Copyright © 1999 -- &quot;;
print &quot;<A href=\&quot; -- &quot;;
print &quot;All Rights Reserved.&quot;;
print &quot;</font></Center></td></tr>&quot;;
print &quot;</table>&quot;;
print &quot;</center>&quot;;
print &quot;</body></html>&quot;;
die
}

print NUMBER &quot;$num&quot;;
close (NUMBER);

## Return an INVOICE page
print &quot;Content-type: text/html\n\n&quot;;
print &quot;<html><head><title>$site_mailname Invoice $num for $FORM{'billName'}</title></head>\n&quot;;
print &quot;<body>\n&quot;;
print &quot;<CENTER>\n&quot;;
print &quot;<table border=0 cellpadding=0 cellspacing=0 width=570>\n&quot;;
print &quot;<tr><td align=left colspan=2>\n&quot;;
print &quot;<font face=\&quot;Arial,Helvetica\&quot; size=5 color=blue>&quot;;
print &quot;$site_name</td></tr>\n&quot;;
print &quot;<tr><td colspan=2><hr size=0></td></tr>\n&quot;;
print &quot;<tr>\n<td><font size=4 face=\&quot;arial\&quot;>Invoice \# $num</td>\n&quot;;
print &quot;<td align=right><font face=\&quot;verdana\&quot; size=2 color=red>$date</td>\n</tr>\n&quot;;
print &quot;<tr><td colspan=2> </td></tr>\n&quot;;
print &quot;</table>\n&quot;;

print &quot;<table border=0 cellpadding=2 cellspacing=0 width=570>&quot;;

if ($FORM{'sendcheck'} eq &quot;yes&quot;) {
print &quot;<tr><td colspan=3><font face=\&quot;verdana\&quot; size=2>&quot;;
print &quot;<b>Congratulations!</b> &quot;;
print &quot;Your order has been processed. Please print and mail this invoice with &quot;;
print &quot;your check or money order to the address listed below your order details. &quot;;
print &quot;You will also be receiving an e-mail with the same information shortly. &quot;;
print &quot;If you have any questions you can email us at &quot;;
print &quot;<a href=\&quot;mailto:$client_note_email\&quot;>$client_note_email</a>.</font></td></tr> &quot;;
print &quot;<tr><td colspan=2> </td></tr></table>\n&quot;;
} else {
print &quot;<tr><td colspan=3><font face=\&quot;verdana\&quot; size=2>&quot;;
print &quot;<b>Congratulations!</b> &quot;;
print &quot;Your order has been processed. Please print this page as your &quot;;
print &quot;receipt. You will also be receiving an e-mail with the same &quot;;
print &quot;information shortly. If you have questions you can &quot;;
print &quot;email us at <a href=\&quot;mailto:$client_note_email\&quot;>$client_note_email</a>.</td></tr> &quot;;
print &quot;<tr><td colspan=2> </td></tr>\n&quot;;
print &quot;</table>&quot;;
}


# Format the items in the array into a table of items ordered
print &quot;<table border=1 cellpadding=2 cellspacing=0 width=570>\n&quot;;
print &quot;<tr bgcolor=#FFFFCC>\n&quot;;
print &quot;<td align=center><font face=\&quot;arial\&quot; size=2 color=black><strong>Qty</strong></td>\n&quot;;
print &quot;<td align=center><font face=\&quot;arial\&quot; size=2 color=black><strong>Item #</strong></td>\n&quot;;
print &quot;<td align=center><font face=\&quot;arial\&quot; size=2 color=black><strong>Item</strong></td>\n&quot;;
print &quot;<td align=center><font face=\&quot;arial\&quot; size=2 color=black><strong>Each</strong></td>\n&quot;;
print &quot;<td align=center><font face=\&quot;arial\&quot; size=2 color=black><strong>Total</strong></td>\n&quot;;

print &quot;</tr>\n&quot;;

$qnty_num = 1;
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$value =~ s/<//g;
$value =~ s/>//g;

# increment quantity - product filenmes
$qnty_check = &quot;quantity_&quot;;
$qnty_check .= $qnty_num;
$prod_check = &quot;product_&quot;;
$prod_check .= &quot;$qnty_num&quot;;

# identify quantity value for this increment
if ($name eq &quot;$qnty_check&quot;) {

# split the product data for this increment
foreach $pair2 (@pairs) {
($name2, $value2) = split(/=/, $pair2);
$value2 =~ tr/+/ /;
$value2 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value2 =~ s/<([^>]|\n)*>//g;
$value2 =~ s/<//g;
$value2 =~ s/>//g;
if ($name2 eq &quot;$prod_check&quot;) {
$product_line = $value2;
}
}

# concentate quantity and product data
$display_line = &quot;$value&quot;;
$display_line .= &quot;----&quot;;
$display_line .= &quot;$product_line&quot;;

# split quantity and product into scalars
($quantity,$item,$description,$price) = split (/----/,$display_line);

# print it in the tables unless quantities zeroed out
unless ($quantity == 0) {
print &quot;<tr>\n&quot;;
print &quot;<td align=\&quot;center\&quot;><font face=\&quot;Arial,Helvetica\&quot; size=2 color=black>$quantity</td> \n&quot;;
print &quot;<td align=\&quot;center\&quot;><font face=\&quot;Arial,Helvetica\&quot; size=2 color=black>$item </td> \n&quot;;
print &quot;<td> <font face=\&quot;Arial,Helvetica\&quot; size=2 color=black>$description </td> \n&quot;;
print &quot;<td align=right><font face=\&quot;Arial,Helvetica\&quot; size=2 color=black> $price </td> \n&quot;;

if ($quantity >= 1) {
$sub_price = ($quantity * $price);
$sub_price = sprintf &quot;%.2f&quot;, $sub_price;
1 while $sub_price =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;

print &quot;<td align=right><font face=\&quot;verdana\&quot; size=2 color=black><b>$sub_price</b> </td> \n&quot;;
}

print &quot;</tr>&quot;;
}


# zero out quantities changed to zero
if ($quantity == 0) {
$price = ($quantity * $price);
}
$sub_price = $quantity * $price;
$qnty_num++;
$count_price += $sub_price;
$count_quantity += $quantity;
}
}

$total_shipCost = ($FORM{'shipCost'} * $count_quantity);

# calculate sales tax and grand total
$sales_tax = ($count_price * $unit_tax);
$grand_total = ($count_price + $total_shipCost);

# format tax and total to 2 decimal places
$count_price = sprintf &quot;%.2f&quot;, $count_price;
$grand_total = sprintf &quot;%.2f&quot;, $grand_total;
$sales_tax = sprintf &quot;%.2f&quot;, $sales_tax;
$total_shipCost = sprintf &quot;%.2f&quot;, $total_shipCost;

# format the math to commas
1 while $count_price =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $sales_tax =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $grand_total =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $count_quantity =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $total_shipCost =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;


# totals for this form

print &quot;<tr><td align=right colspan=3><font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;Total price for <b>$count_quantity</b> products ordered ----></td></font>&quot;;
print &quot;<td bgcolor=#FFFFFF align=right colspan=2> &quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2><b>$count_price</b></font> </td></tr>\n&quot;;
print &quot;<tr><td align=right colspan=3><font face=\&quot;verdana\&quot; size=2>&quot;;
print &quot;Total shipping by <b>$FORM{'shipType'}</b> for <b>$count_quantity</b> items ----></font></td>&quot;;
print &quot;<td bgcolor=#FFFFFF align=right colspan=2> &quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2>$total_shipCost</font> </td></tr>\n&quot;;

# print for check or card
if ($FORM{'sendcheck'} eq &quot;yes&quot;) {
print &quot;<tr><td align=right colspan=3>&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2>&quot;;
print &quot;Make <b>check</b> or <b>money order</b> for this amount ----></font></td>&quot;;
print &quot;<td bgcolor=#FFFFFF align=right colspan=2>&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2>\$<b> $grand_total </b></font></td></tr>\n&quot;;
} else {

if ($FORM{'cardtype'} eq &quot;Visa&quot;) {$type = &quot;Visa Card&quot;;}
if ($FORM{'cardtype'} eq &quot;MasterCard&quot;) {$type = &quot;Master Card&quot;;}
if ($FORM{'cardtype'} eq &quot;AmEx&quot;) {$type = &quot;American Express Card&quot;;}
if ($FORM{'cardtype'} eq &quot;Novus&quot;) {$type = &quot;Discover Card&quot;;}

print &quot;<tr><td align=right colspan=3>&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2>&quot;;
print &quot;Total billed to <b>$type</b> account # <b>$FORM{'cardnumber'}</b> ----></font></td>&quot;;
print &quot;<td bgcolor=#FFFFFF align=right colspan=2>&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2>\$<b> $grand_total </b></font></td></tr>\n&quot;;
}

print &quot;</table>\n&quot;;
print &quot;<table border=0 cellpadding=0 cellspacing=0 width=570>&quot;;
print &quot;<tr><td colspan=3> </td></tr>&quot;;
print &quot;<tr><td width=130 align=left valign=\&quot;middle\&quot;><table border=0 height=35 width=100>&quot;;
print &quot;<tr><td align=center bgcolor=#ebebeb><font face=\&quot;Arial,Helvetica\&quot; size=2><b>Order By:</b></font></td></tr></table>&quot;;
print &quot;</td>&quot;;
print &quot;<td width=220>&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;<b>$FORM{'billName'}<br>\n&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;$FORM{'billAddress'}<br>\n&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;$FORM{'billCity'}, $FORM{'billState'} $FORM{'billZip'}<br>\n&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;$FORM{'billCountry'}</b></td>\n&quot;;
print &quot;<td width=220 align=left valign=top>&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;Phone: <b>$FORM{'billPhone'}</b><br>\n&quot;;

if ($FORM{'billFax'}) {
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;Fax: <b>$FORM{'billFax'}</b><br>\n&quot;;
}

print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>E-Mail: &quot;;
print &quot;<b>$FORM{'billEmail'}</b></td></tr>\n&quot;;
print &quot;<tr><td colspan=3> </td></tr>&quot;;
print &quot;<tr><td width=130 align=left valign=\&quot;middle\&quot;><table border=0 height=35 width=100>&quot;;
print &quot;<tr><td align=center bgcolor=#ebebeb><font face=\&quot;Arial,Helvetica\&quot; size=2><b>Ship To:</b></font></td></tr></table>&quot;;
print &quot;</td>&quot;;
print &quot;<td width=220>&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;<b>$FORM{'shipName'}<br>\n&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;$FORM{'shipAddress'}<br>\n&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;$FORM{'shipCity'}, $FORM{'shipState'} $FORM{'shipZip'}<br>\n&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;$FORM{'shipCountry'}</b></td>\n&quot;;
print &quot;<td width=220 align=left valign=top>&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;Phone: <b>$FORM{'shipPhone'}</b><br>\n&quot;;

if ($FORM{'shipFax'}) {
print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>&quot;;
print &quot;Fax: <b>$FORM{'shipFax'}</b><br>\n&quot;;
}

print &quot;<font face=\&quot;verdana\&quot; size=2 color=black>E-Mail: &quot;;
print &quot;<b>$FORM{'shipEmail'}</b></td></tr>\n&quot;;
print &quot;<tr><td colspan=3><font size=1> </td></tr></table>&quot;;

print &quot;<table width=570 cellspacing=0 cellpadding=0 height=30>&quot;;
print &quot;<tr><td> </td></tr>&quot;;
print &quot;</table>&quot;;

if ($FORM{'sendcheck'} eq &quot;yes&quot;) {

print &quot;<table border=0 cellpadding=2 cellspacing=0 width=360>&quot;;
# print &quot;<tr bgcolor=\&quot;#ebebeb\&quot;>&quot;;
print &quot;<tr>&quot;;
print &quot;<td align=\&quot;center\&quot;><br>&quot;;
print &quot;<font face=\&quot;arial,helvetica\&quot; size=3>&quot;;
print &quot;<b>$site_mailname<br>$site_address<br>$site_city, &quot;;
print &quot;$site_state $site_zip</font></b><br><br><font size=2>&quot;;
print &quot;</td></tr>&quot;;
print &quot;</table>\n&quot;;

} else {

print &quot;<table border=0 cellpadding=2 cellspacing=0 width=570>&quot;;
print &quot;<tr><td> </td></tr>\n&quot;;
print &quot;</table>&quot;;
}

print &quot;<table border=0 cellpadding=2 cellspacing=0 width=570>&quot;;
print &quot;<tr><td colspan=3> </td></tr></table>\n&quot;;

print &quot;<table border=0 cellpadding=2 cellspacing=0 width=570>&quot;;
print &quot;<tr><td><hr size=0></td></tr>&quot;;
print &quot;<tr><td> </td></tr><tr><td><Center><font size=2 face=arial>&quot;;
print &quot;Copyright © $year -- &quot;;
print &quot;<A href=\&quot;$site_location\&quot;>$site_name</A> -- &quot;;
print &quot;All Rights Reserved.&quot;;
print &quot;</font></Center></td></tr>&quot;;
print &quot;</table>&quot;;

print &quot;</CENTER>&quot;;
print &quot;</body></html>\n&quot;;

## Send information to log file
unless (open (LOGFILE, &quot;>>$logfile_path&quot;)) {
print &quot;<html><head><title>File Processing Error !</title></head>&quot;;
print &quot;<body>&quot;;
print &quot;<center><table border=0 cellpadding=2 cellspacing=0 width=90%>&quot;;
print &quot;<tr><td><font face=\&quot;Arial,Helvetica\&quot; size=2> </td></tr>&quot;;
print &quot;<tr><td><font face=\&quot;Arial,Helvetica\&quot; size=2 color=black><strong>&quot;;
print &quot;Note: Logfile processing error.<br></strong>&quot;;
print &quot;<font face=\&quot;Arial,Helvetica\&quot; size=2 color=black>&quot;;
print &quot;There has been a file error attempting to open the log file on the server.<br>&quot;;
print &quot;<strong>$logfile_path</strong><br>&quot;;
print &quot;<strong>No billing has been processed for this invoice</strong><br>&quot;;
print &quot;<font face=\&quot;Arial,Helvetica\&quot; size=2 color=black>&quot;;
print &quot;<strong>Please notify the Merchant <a href=\&quot;mailto:$recipient\&quot;>$recipient</a> &quot;;
print &quot; of this error.</strong></td></tr>&quot;;
print &quot;</table>&quot;;

print &quot;<table border=0 cellpadding=2 cellspacing=0 width=570>&quot;;
print &quot;<tr><td><hr size=0></td></tr>&quot;;
print &quot;<tr><td> </td></tr><tr><td><Center><font size=2 face=arial>&quot;;
print &quot;Copyright © $year -- &quot;;
print &quot;<A href=\&quot;$site_location\&quot;>$site_name</A> -- &quot;;
print &quot;All Rights Reserved.&quot;;
print &quot;</font></Center></td></tr>&quot;;
print &quot;</table>&quot;;

print &quot;</center></body></html>\n&quot;;
die
}

# format the date
($mday,$mon,$year) = (localtime(time))[3,4,5];
$year += 1900;
$mon+=1;

# printing to Log File
print LOGFILE &quot;\n&quot;;
print LOGFILE &quot; INVOICE NUMBER $num \n\n&quot;;
print LOGFILE &quot; DATE $mon-$mday-$year\n\n&quot;;
print LOGFILE &quot; Customer Address :\n&quot;;
print LOGFILE &quot; ----------------------\n&quot;;
print LOGFILE &quot; Name $FORM{'billName'}\n&quot;;
print LOGFILE &quot; Address $FORM{'billAddress'}\n&quot;;
print LOGFILE &quot; C,S,Z $FORM{'billCity'}, $FORM{'billState'} $FORM{'billZip'}\n&quot;;
print LOGFILE &quot; Country $FORM{'billCountry'}\n&quot;;
print LOGFILE &quot; Phone $FORM{'billPhone'}\n&quot;;

if ($FORM{'billFax'}) {
print LOGFILE &quot; Fax $FORM{'billFax'}\n&quot;; }

if ($FORM{'billEmail'}) {
print LOGFILE &quot; Email $FORM{'billEmail'}\n\n&quot;; }
print LOGFILE &quot; Shipping Address :\n&quot;;
print LOGFILE &quot; ----------------------\n&quot;;
print LOGFILE &quot; Name $FORM{'shipName'}\n&quot;;
print LOGFILE &quot; Address $FORM{'shipAddress'}\n&quot;;
print LOGFILE &quot; C,S,Z $FORM{'shipCity'}, $FORM{'shipState'} $FORM{'shipZip'}\n&quot;;
print LOGFILE &quot; Country $FORM{'shipCountry'}\n&quot;;
print LOGFILE &quot; Phone $FORM{'shipPhone'}\n&quot;;

if ($FORM{'shipFax'}) {
print LOGFILE &quot; Fax $FORM{'shipFax'}\n&quot;; }

if ($FORM{'shipEmail'}) {
print LOGFILE &quot; Email $FORM{'shipEmail'}\n\n&quot;; }
print LOGFILE &quot; Payment & Shipping :\n&quot;;
print LOGFILE &quot; ----------------------\n&quot;;
if ($FORM{'sendcheck'} eq &quot;yes&quot;) {
print LOGFILE &quot; -Paying by Check or Money Order.\n&quot;;
} else {
print LOGFILE &quot; -Paying by $FORM{'cardtype'} for $FORM{'cardholder'}.\n&quot;;
print LOGFILE &quot; $FORM{'cardnumber'} Expiration $FORM{'cardmonth'}/$FORM{'cardyear'}.\n&quot;;
}
print LOGFILE &quot; -Shipping by '$FORM{'shipType'}' \@ $FORM{'shipCost'} each.\n\n&quot;;
# Format the ordered items in the array for printing
print LOGFILE &quot; Products Ordered :\n&quot;;
print LOGFILE &quot; ----------------------\n&quot;;

$qnty_num = 1;
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$value =~ s/<//g;
$value =~ s/>//g;

# increment quantity - product filenmes
$qnty_check = &quot;quantity_&quot;;
$qnty_check .= $qnty_num;
$prod_check = &quot;product_&quot;;
$prod_check .= &quot;$qnty_num&quot;;

# identify quantity value for this increment
if ($name eq &quot;$qnty_check&quot;) {

# split the product data for this increment
foreach $pair2 (@pairs) {
($name2, $value2) = split(/=/, $pair2);
$value2 =~ tr/+/ /;
$value2 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value2 =~ s/<([^>]|\n)*>//g;
$value2 =~ s/<//g;
$value2 =~ s/>//g;
if ($name2 eq &quot;$prod_check&quot;) {
$product_line = $value2;
}
}

# put quantity and product data in one long string
$order_line = &quot;$value&quot;;
$order_line .= &quot;----&quot;;
$order_line .= &quot;$product_line&quot;;

# split quantity and product into scalars
($quantity,$item,$description,$price) = split (/----/,$order_line);


# get the sub total or zero value for quantity and item
$sub_price2 = ($quantity * $price);

$qnty_num++;
$count_price2 += $sub_price2;
$count_quantity2 += $quantity;

$sub_price2 = sprintf &quot;%.2f&quot;, $sub_price2;
1 while $sub_price2 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;

$price2 = $price;
$price2 = sprintf &quot;%.2f&quot;, $price2;
1 while $price2 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;



# printing of order list with zero check
unless ($quantity == 0) {
print LOGFILE &quot; $quantity -- $item -- $description -- ($price2/each) Total \$ $sub_price2\n&quot;;
}



}
}

# calculate sales tax and grand total
$sales_tax2 = ($count_price2 * $unit_tax);
$grand_total2 = ($count_price2 + $total_shipCost);

# format tax and total to 2 decimal places
$count_price2 = sprintf &quot;%.2f&quot;, $count_price2;
$grand_total2 = sprintf &quot;%.2f&quot;, $grand_total2;
$total_shipCost = sprintf &quot;%.2f&quot;, $total_shipCost;

# format the math to commas
1 while $count_price2 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $sales_tax2 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $grand_total2 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $count_quantity2 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $total_shipCost =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;

# totals for this order
print LOGFILE &quot;\n&quot;;
print LOGFILE &quot; Total products ordered = $count_quantity2\n&quot;;
print LOGFILE &quot; Total price for these products = \$ $count_price2\n&quot;;
print LOGFILE &quot; Total shipping for $count_quantity2 product(s) = \$ $total_shipCost\n&quot;;
print LOGFILE &quot; Grand Total of this invoice = \$ $grand_total2\n\n&quot;;
print LOGFILE &quot; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++&quot;;
print LOGFILE &quot;\n&quot;;
close(LOGFILE);

## Send invoice for billing via email
if ($mail eq '1') {
open (MYMAIL, &quot;|$mailprog -t&quot;) || die &quot;Can't open $mailprog!\n&quot;;
print MYMAIL &quot;To: $recipient ($site_mailname)\n&quot;;
print MYMAIL &quot;From: $FORM{'billEmail'} ($FORM{'billName'})\n&quot;;
print MYMAIL &quot;Subject: $site_mailname invoice # $num\n\n&quot;;

# printing to Mail program
print MYMAIL &quot;\n&quot;;
print MYMAIL &quot; INVOICE NUMBER $num \n\n&quot;;
print MYMAIL &quot; DATE $mon-$mday-$year\n\n&quot;;
print MYMAIL &quot; Customer Address :\n&quot;;
print MYMAIL &quot; $separator\n&quot;;
print MYMAIL &quot; Name $FORM{'billName'}\n&quot;;
print MYMAIL &quot; Address $FORM{'billAddress'}\n&quot;;
print MYMAIL &quot; C,S,Z $FORM{'billCity'}, $FORM{'billState'} $FORM{'billZip'}\n&quot;;
print MYMAIL &quot; Country $FORM{'billCountry'}\n&quot;;
print MYMAIL &quot; Phone $FORM{'billPhone'}\n&quot;;

if ($FORM{'billFax'}) {
print MYMAIL &quot; Fax $FORM{'billFax'}\n&quot;; }

if ($FORM{'billEmail'}) {
print MYMAIL &quot; Email $FORM{'billEmail'}\n\n&quot;; }
print MYMAIL &quot; Shipping Address :\n&quot;;
print MYMAIL &quot; $separator\n&quot;;
print MYMAIL &quot; Name $FORM{'shipName'}\n&quot;;
print MYMAIL &quot; Address $FORM{'shipAddress'}\n&quot;;
print MYMAIL &quot; C,S,Z $FORM{'shipCity'}, $FORM{'shipState'} $FORM{'shipZip'}\n&quot;;
print MYMAIL &quot; Country $FORM{'shipCountry'}\n&quot;;
print MYMAIL &quot; Phone $FORM{'shipPhone'}\n&quot;;

if ($FORM{'shipFax'}) {
print MYMAIL &quot; Fax $FORM{'shipFax'}\n&quot;; }

if ($FORM{'shipEmail'}) {
print MYMAIL &quot; Email $FORM{'shipEmail'}\n\n&quot;; }
print MYMAIL &quot; Payment & Shipping :\n&quot;;
print MYMAIL &quot; $separator\n&quot;;
if ($FORM{'sendcheck'} eq &quot;yes&quot;) {
print MYMAIL &quot; Paying by Check or Money Order.\n&quot;;
} else {
print MYMAIL &quot; $FORM{'cardtype'} for $FORM{'cardholder'}.\n&quot;;
print MYMAIL &quot; $FORM{'cardnumber'} Expiration $FORM{'cardmonth'}/$FORM{'cardyear'}.\n&quot;;
}
print MYMAIL &quot; Shipping by '$FORM{'shipType'}'.\n\n&quot;;
# Format the ordered items in the array for printing
print MYMAIL &quot; Products Ordered :\n&quot;;
print MYMAIL &quot; $separator\n&quot;;

$qnty_num = 1;
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$value =~ s/<//g;
$value =~ s/>//g;

# increment quantity - product filenmes
$qnty_check = &quot;quantity_&quot;;
$qnty_check .= $qnty_num;
$prod_check = &quot;product_&quot;;
$prod_check .= &quot;$qnty_num&quot;;

# identify quantity value for this increment
if ($name eq &quot;$qnty_check&quot;) {

# split the product data for this increment
foreach $pair3 (@pairs) {
($name3, $value3) = split(/=/, $pair3);
$value3 =~ tr/+/ /;
$value3 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value3 =~ s/<([^>]|\n)*>//g;
$value3 =~ s/<//g;
$value3 =~ s/>//g;
if ($name3 eq &quot;$prod_check&quot;) {
$product_line = $value3;
}
}

# put quantity and product data in one long string
$order_line = &quot;$value&quot;;
$order_line .= &quot;----&quot;;
$order_line .= &quot;$product_line&quot;;

# split quantity and product into scalars
($quantity,$item,$description,$price) = split (/----/,$order_line);


# get the sub total or zero value for quantity and item
$sub_price3 = ($quantity * $price);
$sub_price3 = sprintf &quot;%.2f&quot;, $sub_price3;

$qnty_num++;
$count_price3 += $sub_price3;
$count_quantity3 += $quantity;

1 while $sub_price3 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;

# printing of order list with zero check
unless ($quantity == 0) {
print MYMAIL &quot; $quantity - $item - $description - ($price/each) Total \$ $sub_price3\n&quot;;
}


}
}

# calculate sales tax and grand total
$sales_tax3 = ($count_price3 * $unit_tax);
$grand_total3 = ($count_price3 + $total_shipCost);

# format tax and total to 2 decimal places
$count_price3 = sprintf &quot;%.2f&quot;, $count_price3;
$grand_total3 = sprintf &quot;%.2f&quot;, $grand_total3;
$total_shipCost = sprintf &quot;%.2f&quot;, $total_shipCost;

# format the math to commas
1 while $count_price3 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $sales_tax3 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $grand_total3 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $count_quantity3 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $total_shipCost =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;

# totals for this order
print MYMAIL &quot;\n&quot;;
print MYMAIL &quot; Total products ordered = $count_quantity3\n&quot;;
print MYMAIL &quot; Total price for these products = \$ $count_price3\n&quot;;
print MYMAIL &quot; Total shipping for $count_quantity3 product(s) = \$ $total_shipCost\n&quot;;
print MYMAIL &quot; Grand Total of this invoice = \$ $grand_total3\n\n&quot;;
print MYMAIL &quot; Another Order From The Internet!&quot;;
print MYMAIL &quot;\n&quot;;
close(MYMAIL);
}

## Send invoice for billing via email
if ($mail eq '1') {
open (MAIL, &quot;|$mailprog -t&quot;) || die &quot;Can't open $mailprog!\n&quot;;
print MAIL &quot;From: $recipient ($site_mailname)\n&quot;;
print MAIL &quot;To: $FORM{'billEmail'} ($FORM{'billName'})\n&quot;;
print MAIL &quot;Subject: $site_mailname invoice # $num\n\n&quot;;

# printing to Mail program
print MAIL &quot;\n&quot;;
print MAIL &quot; INVOICE NUMBER $num \n\n&quot;;
print MAIL &quot; DATE $mon-$mday-$year\n\n&quot;;
print MAIL &quot; Customer Address :\n&quot;;
print MAIL &quot; $separator\n&quot;;
print MAIL &quot; Name $FORM{'billName'}\n&quot;;
print MAIL &quot; Address $FORM{'billAddress'}\n&quot;;
print MAIL &quot; C,S,Z $FORM{'billCity'}, $FORM{'billState'} $FORM{'billZip'}\n&quot;;
print MAIL &quot; Country $FORM{'billCountry'}\n&quot;;
print MAIL &quot; Phone $FORM{'billPhone'}\n&quot;;

if ($FORM{'billFax'}) {
print MAIL &quot; Fax $FORM{'billFax'}\n&quot;; }

if ($FORM{'billEmail'}) {
print MAIL &quot; Email $FORM{'billEmail'}\n\n&quot;; }
print MAIL &quot; Shipping Address :\n&quot;;
print MAIL &quot; $separator\n&quot;;
print MAIL &quot; Name $FORM{'shipName'}\n&quot;;
print MAIL &quot; Address $FORM{'shipAddress'}\n&quot;;
print MAIL &quot; C,S,Z $FORM{'shipCity'}, $FORM{'shipState'} $FORM{'shipZip'}\n&quot;;
print MAIL &quot; Country $FORM{'shipCountry'}\n&quot;;
print MAIL &quot; Phone $FORM{'shipPhone'}\n&quot;;

if ($FORM{'shipFax'}) {
print MAIL &quot; Fax $FORM{'shipFax'}\n&quot;; }

if ($FORM{'shipEmail'}) {
print MAIL &quot; Email $FORM{'shipEmail'}\n\n&quot;; }
print MAIL &quot; Payment & Shipping :\n&quot;;
print MAIL &quot; $separator\n&quot;;
if ($FORM{'sendcheck'} eq &quot;yes&quot;) {
print MAIL &quot; Paying by Check or Money Order.\n&quot;;
} else {
print MAIL &quot; $FORM{'cardtype'} for $FORM{'cardholder'}.\n&quot;;
print MAIL &quot; $FORM{'cardnumber'} Expiration $FORM{'cardmonth'}/$FORM{'cardyear'}.\n&quot;;
}
print MAIL &quot; Shipping by '$FORM{'shipType'}'.\n\n&quot;;
# Format the ordered items in the array for printing
print MAIL &quot; Products Ordered :\n&quot;;
print MAIL &quot; $separator\n&quot;;

$qnty_num = 1;
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$value =~ s/<//g;
$value =~ s/>//g;

# increment quantity - product filenmes
$qnty_check = &quot;quantity_&quot;;
$qnty_check .= $qnty_num;
$prod_check = &quot;product_&quot;;
$prod_check .= &quot;$qnty_num&quot;;

# identify quantity value for this increment
if ($name eq &quot;$qnty_check&quot;) {

# split the product data for this increment
foreach $pair4 (@pairs) {
($name4, $value4) = split(/=/, $pair4);
$value4 =~ tr/+/ /;
$value4 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$value4 =~ s/<([^>]|\n)*>//g;
$value4 =~ s/<//g;
$value4 =~ s/>//g;
if ($name4 eq &quot;$prod_check&quot;) {
$product_line = $value4;
}
}

# put quantity and product data in one long string
$order_line = &quot;$value&quot;;
$order_line .= &quot;----&quot;;
$order_line .= &quot;$product_line&quot;;

# split quantity and product into scalars
($quantity,$item,$description,$price) = split (/----/,$order_line);


# get the sub total or zero value for quantity and item
$sub_price4 = ($quantity * $price);
$sub_price4 = sprintf &quot;%.2f&quot;, $sub_price4;

$qnty_num++;
$count_price4 += $sub_price4;
$count_quantity4 += $quantity;

1 while $sub_price4 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;

# printing of order list with zero check
unless ($quantity == 0) {
print MAIL &quot; $quantity - $item - $description - ($price/each) Total \$ $sub_price4\n&quot;;
}


}
}

# calculate sales tax and grand total
$sales_tax4 = ($count_price4 * $unit_tax);
$grand_total4 = ($count_price4 + $total_shipCost);

# format tax and total to 2 decimal places
$count_price4 = sprintf &quot;%.2f&quot;, $count_price4;
$grand_total4 = sprintf &quot;%.2f&quot;, $grand_total4;
$total_shipCost = sprintf &quot;%.2f&quot;, $total_shipCost;

# format the math to commas
1 while $count_price4 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $sales_tax4 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $grand_total4 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $count_quantity4 =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;
1 while $total_shipCost =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/;

# totals for this order
print MAIL &quot;\n&quot;;
print MAIL &quot; Total products ordered = $count_quantity4\n&quot;;
print MAIL &quot; Total price for these products = \$ $count_price4\n&quot;;
print MAIL &quot; Total shipping for $count_quantity4 product(s) = \$ $total_shipCost\n&quot;;
print MAIL &quot; Grand Total of this invoice = \$ $grand_total4\n\n&quot;;
print MAIL &quot; Thank you for your support in $site_mailname products!&quot;;
print MAIL &quot;\n&quot;;
close(MAIL);
}

## Open Mail Program To Prepare To Send Client Notification of Order

open (NOTEMAIL, &quot;|$mailprog -t&quot;) || die &quot;Can't open $mailprog!\n&quot;;

## Print E-Mail Headers To Email Program

print NOTEMAIL &quot;From: Merchant Host Post Office Server\n&quot;;
print NOTEMAIL &quot;To: $client_note_email\n&quot;;
print NOTEMAIL &quot;Subject: TAPE ORDER\n\n&quot;;

## Print Message To Mail Program

print NOTEMAIL &quot;IMPORTANT NOTICE - CHECK YOUR POST OFFICE FOR A RECENT ORDER!\n&quot;;
print NOTEMAIL &quot;$separator\n\n&quot;;
print NOTEMAIL &quot;A secure email has been sent to your server Post Office containing sensitive information.\n\n&quot;;
print NOTEMAIL &quot;Please login at enter your \n&quot;;
print NOTEMAIL &quot;username and password, and retrieve your mail. You may copy and paste to your \n&quot;;
print NOTEMAIL &quot;favorite word processing program or print a copy for your records.\n\n&quot;;
print NOTEMAIL &quot;Please delete the email after you have retrieved your information.\n\n&quot;;
print NOTEMAIL &quot;Thank you for allowing us to be of service.\n\n&quot;;

## Close Mail Program

close(NOTEMAIL);
_______________________________________________________
 
You really can't expect us to look through miles of code like that. Try using the following code to capture errors. Put it at the top of your script.
Code:
use CGI::Carp qw(fatalsToBrowser carpout);
BEGIN {
    open(LOG, &quot;>>path/to/an/error/log&quot;) or confess &quot;Can't open error log! $!&quot;;
    carpout(LOG); 
}

Then give us the relvant code and the error message it gives you.
 
Hi, thanks for the piece of code, i put it at the top of each script and pointed it to three different log files and chmod each one 777, and it did not write to them and did not get a error message, the only error that came up was the error 500 that i am trying to figure out,
does anyone have/know of any other pieces of debugging code?
thanks
steve
 
I can only assume that you posted the entire script, so I don't see where you set $number_path.

It gets used here:

unless (open (NUMBER, &quot;$number_path&quot;)) {

without ever being defined. Same with $site_state and some others.

Are these defined in the order00.cfg?

jaa
 
Also, you should change your die() statements to be more informative.

At the very minimum add $! so you get a reason why the script dies.

jaa
 
- Do you have CGI::Carp installed?
- I put fatalsToBrowser in there, so it should catch compile-time as well as run-time errors and put 'em in the browser.

Your server error log doesn't say anything?
 
The browser will return a 500 error if no text is sent to the browser - even if there are no syntax errors.

For example:

if ($asdf == $qwerty)
{
print &quot;Content-type: text/html&quot;, &quot;\n\n&quot;;
print &quot;<body>fasdfasdf</body>&quot;;
}
############
# end code #
############

if $asdf does not equal $qwerty then that code will not be executed. therefore, no text will be sent to the browser. thus, giving 500 error even if there are no syntax errors.

I did not look over your code so im not saying that is the problem. Im just telling you that that could be a possibility.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top