All in the following code snippet - I have this code working without syntax error if a user accesses the page directly they get the message listed in the else statement "This page cannot be accessed directly " - and when the user accesses the page from a post method it e-mail it to the proper e-mail box. However what doesn't show up in the e-mail is any of the variables - example: $order $subtotal $promo $tax $shipping $total - so I get the e-mail but it doesn't have any of the values from my form - so therefore am I missing a bracket or need some other logic change so the e-mail has my variables:

if ($ENV{'REQUEST_METHOD'} eq "POST") {

$to = "orderemail\@mysite.net";
$date = todays-date;

&Email;
&Thanks;
&HTML;

sub Email {
open (MAIL, "| /usr/sbin/sendmail "
      . "-F\" $name\" "
      . "-f\" $email\" "
      . "$to" )
    || die "x\n\n(*)Sendmail returned error code. Halting. \n\n";
$header = "Date: $date\n"
    . "To: $to\n"
    . "Subject: New Order\n\n";

$message .= "ITEM     DESIGN   DESCRIP.              QUAN. PRICE EA.\n";
$message .= "-------------------------------------------------------\n";
$message .= "$order\n\n";
$message .= " subtotal: $subtotal\n";
$message .= "    promo: $promo PROMOTIONAL PRICE\n";
$message .= "sales tax: $tax\n";
$message .= " shipping: $shipping\n";
$message .= "    TOTAL: $total\n\n";

print MAIL "$header";
print MAIL "$message";
close(MAIL);

}

sub Thanks {
open (MAIL, "| /usr/sbin/sendmail "
      . "-F\" $to\" "
      . "-f\" $to\" "
      . "$email" )
    || die "x\n\n(*)Sendmail returned error code. Halting. \n\n";
$header2 = "Date: $date\n"
    . "To: $email\n"
    . "Subject: promo confirmation\n\n";

$message2 .= "-------------------------------------------------------\n";
$message2 .= "Thank you for your order! Your item will ship tomorrow via the USPS. \n\n";
$message2 .= "-------------------------------------------------------\n";
print MAIL "$header2";
print MAIL "$message2";
close(MAIL);

}

sub HTML {
print << "EndOfHTML";

<HTML>
<HEAD>
<TITLE>Promo Order</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff" BACKGROUND="../../images/yellowBarBG.gif" LINK="#000000" ALINK="#bb0000" VLINK="#000000">
<TABLE BORDER=0 WIDTH=600>
<TR VALIGN="top">
    <TD WIDTH="150" ALIGN="left">
<CENTER>
<FONT SIZE=1>Promos</FONT><BR>
<U><B>P R O M O<BR>C O M P L E T E</B></U><BR>
<BR>
</CENTER>
<FONT SIZE=2>
Thank you for placing your promo with us!
<BR><BR><BR>
<CENTER>
<A HREF="/">return to front page</A>
<BR><BR>
</CENTER>
</FONT>
</TD>
<TD WIDTH="50">&nbsp;&nbsp;</TD>
<TD WIDTH="400">
<CENTER>
<FONT SIZE=4>THANK YOU!</FONT><BR><BR><BR>
</CENTER>
</TD>
</TR>
</TABLE>

</BODY>
</HTML>

EndOfHTML
}

} else { 

print "This page cannot be accessed directly";

} 

Hi,

You need to get the parameters for post params before you can use them in your email template.
Suppose that you have {name, email, order, subtotal, promo, tax, shipping, total} fields in your form, you need to write code like below before making MAIL call :

my $query = new CGI;

my $name = $query->param('name');
my $email = $query->param('email');
my $order = $query->param('order');
my $subtotal = $query->param('subtotal');
my $promo = $query->param('promo');
my $tax = $query->param('tax');
my $shipping = $query->param('shipping');
my $total = $query->param('total');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.