[ back to toc ]

Quick little problem . . . again!

Date: 2001/12/22 03:18

Q:
Sorry to bother you again . . . I have a couple of quick questions about
this CGI.pm script which is working fine now, mostly thanks to you!

=========================================

use CGI qw(:standard);

$lastname = param('LName');
$firstname = param('FName');
$address = param('Address');
$add2 = param('Add2');
$city = param('City');
$state = param('State');
$zip = param('Zip');
$telephone = param('Telephone');
$fax = param('FAX');
$email = param('Email');
$incom = param('Comments');
@qty = param('Qty');
@product = param('Product');
@price = param('Price');
@subtot = param('SubTotal');
$timenow = localtime;

$fromuser = 'metazai@yahoo.com';
$to = $email;
$subject = 'Contact Message';
$messagebody =

"Contact Message received on $timenow

Product @product
Price: @price
Quantity: @qty
Subtotal: @subtot

Lastname: $lastname
Firstname: $firstname

Address: $address
Company: $add2
City: $city
State: $state
ZipCode: $zip

Telephone: $telephone
FAX: $fax

EMAIL: $email

Comments:

$incom

THIS ORDER HAS BEEN PLACED PENDING APPROVAL OF YOUR CREDIT CARD
INFORMATION. YOU WILL BE CONTACTED IF THERE IS A PROBLEM.

End Contact message
---------------------------------------------";

use Net::SMTP;
$smtp = Net::SMTP->new('localhost');
$smtp->mail($fromuser);
$smtp->to("metazai\@yahoo.com\n");
$smtp->data();
$smtp->datasend($touser);
$smtp->datasend("From: metazai\@yahoo.com\n");
$smtp->datasend("\n");
$smtp->datasend($messagebody);
$smtp->dataend();
$smtp->quit;

$ThePage = <<"BLARG";
<html>
<HEAD>
<TITLE>HTML REDIRECT</TITLE>
<META HTTP-EQUIV="REFRESH" CONTENT="5;
URL=https://www.americaninternet.com/abasketcompany/finalorder.htm">

<title>Thank You</title>
</HEAD>

<body>
<h3 align = center>Processing order . . .</h3>
<p align = center>The process should continue in 5 seconds</p>
<p align = center>If you don't want to wait, <a
href="https://www.americaninternet.com/abasketcompany/finalorder.htm">
Click
Here</a>.</p>
</body>
</html>
BLARG

print "content-type: text/html\n\n";
print "$ThePage";

================================

When I display the contents of the variables: @qty, @product, @price, and
@subtot in my mail readout (the part that begins with
"-------------------------------------------- Contact Message received on
$timenow . . .) is there a way I can format the multiple values found in
each of these variables? Here's what I mean: if someone were to order 4
items, right now I get the results as

xxxxxxxxx,xxxxx,xxxxxxxxxxx,xx
#,#,#,#
$$$$,$$$$,$$$$,$$$$
++++,++++,++++,++++,++++

Is there a bit of code to format the results as:

xxxxxxxxx,#,$$$$,++++
xxxxx,#,$$$$,++++
xxxxxxxxxxx,#,$$$$,++++
xx,#,$$$$,++++

???

Also, using the "use Net::SMTP;" command, is there a way I can cc: to the
$email variable?

If I can clear up these two issues, I won't be pestering you again. I was
impressed with the speed and insight you showed last time (although mostly
it was just finding a dumb mistake on my part =+0 )

Thanks!

*NAME-DELETED*

A:
I volunteered to answer no more than 4 questions a day here, so do not
feel ashamed asking.

Perl is really powerful in formatting print output, though it seems that
people tend to forget this. Perl was originally developed for writing text
reports, thus there are fairly well formatting commands.

To get detailed information visit

http://www.perldoc.com/perl5.6/pod/perlform.html

I have not used it ever though.

To CC someone of the mail you can try to add another $smtp->to() adressee.
I do not know if it work or not. If not then you have to send the mail
twice. Also add $smtp->data("Cc: addressee") to the header part.

Regards,
Peter

[ back to toc ]