cafetom
07-16-2003, 09:32 PM
This is my first stab at writing subroutine in perl.
The sub is to match user inputted zip code and send
an email to the sales rep serving that zip code area.
I cannot get it to work. Does anyone have any ideas?
Here is the html page...
<HTML>
<HEAD>
<TITLE>Test Catalog Order Form</TITLE>
</HEAD>
<body bgcolor="#800000" link="#FFFFFF" vlink="#EF9C00" alink="#C0C0C0">
<p>
<table BORDER=0 COLS=1 WIDTH="65%" align=center>
<tr>
<td><center><font face="Tempus Sans ITC" color="white">
<h2><b>Harvest Group Marketing Associates
</h2></center></font></td>
</tr>
</table>
<FORM NAME="Catorder" METHOD="POST" ACTION="http://www.harvestgroupma.com/cgi-bin/guest2.pl">
<Table width="550" align="center" BORDER="0">
<tr>
<td width=50% align=right>
<font color="white">
<b>Name:</b></font>
<INPUT TYPE=TEXT NAME="name">
</td>
<td width=50%>
<font color="white"><b>Company Name:</b></font><INPUT TYPE=TEXT NAME="title">
</td>
<tr>
<td width=50% align=right>
<font color="white"><b>Email:</b></font>
<INPUT TYPE=TEXT NAME="email">
</td>
<td width=50%>
<font color="white"><b>Zip Code:</b></font>
<INPUT TYPE=TEXT NAME="zip"></td>
</tr>
</table>
<br>
<table width="50%" border="1" ALIGN="CENTER">
<tr>
<td colspan="4" bgcolor="#B8860B">
<b>Want to order a catalog?</b></td>
</tr>
<tr>
<td bgcolor="#DAA520" nowrap>
<input type="checkbox" name="catalog" value="PopCorn Gifts"><b><font color="black">PopCorn Gifts</font></b>
</td>
<td bgcolor="#DAA520" nowrap>
<input type="checkbox" name="catalog" value="Food Gifts"><b><font color="black">Food Gifts</font></b>
</td>
</tr>
</table>
<P align="CENTER">
<INPUT TYPE=submit VALUE="SEND">
<INPUT TYPE=reset VALUE="CLEAR">
</form>
</body>
</html>
Here is the Perl Script...
#!/usr/local/bin/perl
#######################
#Catalog Order Script #
#Tom Fitzsimmons #
#######################
#
# Create the CGI Object
#
use CGI;
my $q = new CGI;
#
# Output the HTTP Header
#
print "Content-type:text/html\n\n";
#
# Set up the variables
#
@CATALOG = $q->param('catalog');
$name = $q->param('name');
$company = $q->param('title');
$email1 = $q->param('email');
$zip = $q->param('zip');
#
# Match User Zip Codes to get $recipient e-mail
#
sub zipmail
{
my ($zip, $recipient);
$recipent = ;
foreach $zip(@_)
{
if(($zip >=17701 && $zip <=17703) | $zip == 17704 | ($zip >=17706 && $zip <= 17799))
{
$recipent = "cookies@micro-link.net";
}
elsif($zip == 17705)
{
$recipent = "psutom@micro-link.net";
}
return $recipient;
}
}
#
# Redirect the Browser Page using unordered list "<ul></ul>"
#
print "<html>";
print "<h2>Thanks, $name for your order!</h1>";
print "<br>";
print "<h3>On behalf of $company, $name has ordered:";
print "<ul>";
foreach $CATALOG (@CATALOG) { print "<li>$CATALOG \n"; }
print "</ul>";
print "These catalogs will be shipped within two business days.</h3><br>";
print "An e-mail confirmation has been sent to $recipient
</h3><br>";
print "</html>";
exit(0);
Thanks,
Tomsweb :confused:
The sub is to match user inputted zip code and send
an email to the sales rep serving that zip code area.
I cannot get it to work. Does anyone have any ideas?
Here is the html page...
<HTML>
<HEAD>
<TITLE>Test Catalog Order Form</TITLE>
</HEAD>
<body bgcolor="#800000" link="#FFFFFF" vlink="#EF9C00" alink="#C0C0C0">
<p>
<table BORDER=0 COLS=1 WIDTH="65%" align=center>
<tr>
<td><center><font face="Tempus Sans ITC" color="white">
<h2><b>Harvest Group Marketing Associates
</h2></center></font></td>
</tr>
</table>
<FORM NAME="Catorder" METHOD="POST" ACTION="http://www.harvestgroupma.com/cgi-bin/guest2.pl">
<Table width="550" align="center" BORDER="0">
<tr>
<td width=50% align=right>
<font color="white">
<b>Name:</b></font>
<INPUT TYPE=TEXT NAME="name">
</td>
<td width=50%>
<font color="white"><b>Company Name:</b></font><INPUT TYPE=TEXT NAME="title">
</td>
<tr>
<td width=50% align=right>
<font color="white"><b>Email:</b></font>
<INPUT TYPE=TEXT NAME="email">
</td>
<td width=50%>
<font color="white"><b>Zip Code:</b></font>
<INPUT TYPE=TEXT NAME="zip"></td>
</tr>
</table>
<br>
<table width="50%" border="1" ALIGN="CENTER">
<tr>
<td colspan="4" bgcolor="#B8860B">
<b>Want to order a catalog?</b></td>
</tr>
<tr>
<td bgcolor="#DAA520" nowrap>
<input type="checkbox" name="catalog" value="PopCorn Gifts"><b><font color="black">PopCorn Gifts</font></b>
</td>
<td bgcolor="#DAA520" nowrap>
<input type="checkbox" name="catalog" value="Food Gifts"><b><font color="black">Food Gifts</font></b>
</td>
</tr>
</table>
<P align="CENTER">
<INPUT TYPE=submit VALUE="SEND">
<INPUT TYPE=reset VALUE="CLEAR">
</form>
</body>
</html>
Here is the Perl Script...
#!/usr/local/bin/perl
#######################
#Catalog Order Script #
#Tom Fitzsimmons #
#######################
#
# Create the CGI Object
#
use CGI;
my $q = new CGI;
#
# Output the HTTP Header
#
print "Content-type:text/html\n\n";
#
# Set up the variables
#
@CATALOG = $q->param('catalog');
$name = $q->param('name');
$company = $q->param('title');
$email1 = $q->param('email');
$zip = $q->param('zip');
#
# Match User Zip Codes to get $recipient e-mail
#
sub zipmail
{
my ($zip, $recipient);
$recipent = ;
foreach $zip(@_)
{
if(($zip >=17701 && $zip <=17703) | $zip == 17704 | ($zip >=17706 && $zip <= 17799))
{
$recipent = "cookies@micro-link.net";
}
elsif($zip == 17705)
{
$recipent = "psutom@micro-link.net";
}
return $recipient;
}
}
#
# Redirect the Browser Page using unordered list "<ul></ul>"
#
print "<html>";
print "<h2>Thanks, $name for your order!</h1>";
print "<br>";
print "<h3>On behalf of $company, $name has ordered:";
print "<ul>";
foreach $CATALOG (@CATALOG) { print "<li>$CATALOG \n"; }
print "</ul>";
print "These catalogs will be shipped within two business days.</h3><br>";
print "An e-mail confirmation has been sent to $recipient
</h3><br>";
print "</html>";
exit(0);
Thanks,
Tomsweb :confused: