MattJakel
07-07-2004, 08:48 PM
Well, it's been a month or so since I've really done anything with CGI, so I might just be making a stupid mistake here. I've got a simple script that takes form input and emails it. For the most part, it just gets the key/value pairs and sends them as "$key : $value \n". However, I would like the "formname" field to determine the subject of the email, so I have this part of the script:
$size = $ENV{'CONTENT_LENGTH'};
read (STDIN, $form_info, $size);
my $bodytext;
my $formname;
foreach $pair (split (/&/, $form_info)) {
($key, $value) = split (/=/, $pair);
$key =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
#if ($key eq "formname") {
#$formname = $value;
#} else {
$bodytext = "${bodytext}$key \: $value \n";
#}
}
#if ($formname eq "newsletter") {
#my $subject = "Mailing List Signup";
#my $toaddr = "email\@domain.com";
#} elsif ($formname eq "article") {
#my $subject = "Article Rating";
#my $toaddr = "email\@domain.com";
#} else {
my $subject = "Test";
my $toaddr = "email\@domain.com";
#}
The script works when I comment out the lines commented out in the code above, but when I uncomment them, a blank email is sent. Am I just making a stupid mistake here?
Thanks,
Matt
$size = $ENV{'CONTENT_LENGTH'};
read (STDIN, $form_info, $size);
my $bodytext;
my $formname;
foreach $pair (split (/&/, $form_info)) {
($key, $value) = split (/=/, $pair);
$key =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
#if ($key eq "formname") {
#$formname = $value;
#} else {
$bodytext = "${bodytext}$key \: $value \n";
#}
}
#if ($formname eq "newsletter") {
#my $subject = "Mailing List Signup";
#my $toaddr = "email\@domain.com";
#} elsif ($formname eq "article") {
#my $subject = "Article Rating";
#my $toaddr = "email\@domain.com";
#} else {
my $subject = "Test";
my $toaddr = "email\@domain.com";
#}
The script works when I comment out the lines commented out in the code above, but when I uncomment them, a blank email is sent. Am I just making a stupid mistake here?
Thanks,
Matt