Hi ,
I am completely new to Perl , I cant even say that I am a newbie Perl programmer !! Ive only used it to make a form in Apache (Cobalt) UNIX Server as previously it worked fine in asp with Windows IIS.
So, I have a form that includes two hidden fields named "subject" and "recipient". There are some other inside the form tha the user can write in. Like the "email" which I want to use as a send_to perl variable.
I am close to solution but....
I have included in the script (searching in the Net) these lines:
<code>my $query = new CGI;
my $HTML_thankyou = 'thankyou.htm';
my $to = 'thanas1@hotmail.com';
my $from = $query->param("Email");
my $mailprog = '/usr/sbin/sendmail';
my $subject = $query->param("subject");
</code>
1) I need to take the from variable from the form field "email" (user's typed) Is that ok?
The next part I included in the script is:
<code>%FORM = parse_cgi();
foreach(@field){$message.="$_: $FORM{$_}\n";}
mymail($to, $from, $subject, $message);
print "Location: $HTML_thankyou\n\n";
exit;
sub parse_cgi{
my %FORM; my $name; my $value; my $content;
my $a=0;
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 if $kill_html_tags;
$value =~ s/<([^>]|\n)*>//g if $kill_html_tags;
if($FORM{$name}){$FORM{$name} = ", ".$value;}
else{$FORM{$name} = $value;}
$field[$a++]=$name;
}
$a=0;
$temp=$ENV{'QUERY_STRING'};
@pairs=split(/&/,$temp);
foreach $item(@pairs) {
($key,$content)= split (/=/,$item,2);
$content =~ tr/+/ /;
$content =~ s/%(..)/pack("c",hex($1))/ge;
$content =~ s/<!--(.|\n)*-->//g if $kill_html_tags;
$content =~ s/<([^>]|\n)*>//g if $kill_html_tags;
if($FORM{$key}){$FORM{$key} .= ", ".$content;}
else{$FORM{$key} = $content;}
$field[$a++]=$key;
}
return %FORM;
}
sub mymail{
open(MAIL,"|$mailprog -t");
print MAIL "To: $_[0]\n";
print MAIL "From: $_[1]\n";
print MAIL "Subject: $_[2]\n\n";
print MAIL "$content\n";
close(MAIL);
</code>
I get an email that has the right Subject, the right sender but I dont have any content inside the email ....
What is wrong with the last part of printing the form's content ???
Im Looking forward to reading your answers !