#!/usr/bin/perl # # order2.cgi # $mailprog = "/usr/sbin/sendmail"; print "Content-type:text/html\n\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @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; # added to strip line breaks $value =~ s/\r//g; $value =~ s/\cM//g; $FORM{$name} = $value; } # here we check to make sure they actually filled out all # the fields. if they didn't, generate an error. print "
EndHead
open(INF,"data.db") or dienice("Can't open data.db: $! \n");
@grok = ;
close(INF);
open(MAIL,"|$mailprog -t") or &dienice("Couldn't send mail.");
print MAIL "To: kites\@cgi101.com\n";
print MAIL "Subject: Kite Order from $FORM{'email'}\n\n";
# print the info to the MAIL message:
print MAIL <
Endsub2
# credit card info only input to MAIL
if ($FORM{'paytype'} ne "check") {
print MAIL "Card#: $FORM{'ccno'} Exp: $FORM{'ccexp'}\n";
print MAIL "Billing Address: $FORM{'bill_addr'}\n";
print MAIL "City: $FORM{'bill_city'}\n";
print MAIL "State: $FORM{'bill_state'}\n";
print MAIL "ZIP: $FORM{'bill_zip'}\n";
print "Thank you for your order. Your $FORM{'paytype'} will be
billed for \$$total; you'll receive your order within 7-10 days.\n";
} else {
print "Thank you for your order. Please send a check or money
order for \$$total to: Kite Store, 555 Anystreet, Somecity, TX
12345.
\n";
}
# send the mail!
close(MAIL);
print "\n";
sub dienice {
my($msg) = @_;
print "
Error
\n";
print $msg;
exit;
}