Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with email script 1

Status
Not open for further replies.

angela5780

Programmer
Feb 23, 2007
3
US
I really don’t know what I’m doing, but I need my text fields to import to my email fields so I get an email from the person who fills out the form. The form is in my perl script. Does anyone have any tips on how I can do this. I get a blank email now.

#!/usr/local/bin/perl
read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{

}
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<BODY BGCOLOR=#FFFFFF>\n";
print "<CENTER>\n";
print "JAPANESE WOMEN BOWING IN TRADITIONAL GREETING";

($key,$content)=split(/=/,$item,2);
$content=~tr/+/ /;
$content=~s/%(..)/pack("c",hex($1))/ge;
$fields{$key}=$content;



print "$fields{name}</BR>";
print "$fields{email}<BR>\n";


use CGI ":all";
$radio_action = param("radio_action");
$option = param("option");

print br, "I have agreed to the tems of sale: ", br,
radio_group(-name=>"radio_action",
-values=>['Yes,'],
-default=>'1',-override=>1);
if ($radio_action eq "Yes, I have agreed to the terms of sale")
{

}

$option = param("option");
print "<CENTER>\n";
print header, start_form,

print "I have read and agree to the terms and conditions described in the agreement",br;
print "Name" ,textfield(-name=>'name'),br, print "Email" ,textfield(-email=>'email'), br;

print "<a href=\"
print "</BODY></HTML>";
print end_html;


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

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;
$FORM{$name} = $value;
}


open (MESSAGE,"| /usr/sbin/sendmail -t");

print MESSAGE "To: myaddress\@comcast.net\n"; @!).
print MESSAGE "From: $FORM{name}, reader\n";
print MESSAGE "Reply-to: $FORM{email}\n";

print MESSAGE "Subject: Feedback from $FORM{testform} \n\n";

print MESSAGE "$FORM{testform} wrote:\n\n";
print MESSAGE "Comment: $FORM{comment}\n\n";
print MESSAGE "Sent by: $FORM{testform} ($FORM{email}).\n";

close (MESSAGE);

&thank_you; #method call
}

sub thank_you {

print <<EndStart;

<html>
<head>
<title>Thank You</title>
</head>

<body bgcolor="#ffffff" text="#000000">

<h1>Thank You</h1>


<hr>


EndStart


print "<blockquote><em>$FORM{comment}</em></blockquote>\n\n";

print <<EndHTML;

</body>
</html>

EndHTML

exit(0);
}
 
if that is all one script, you can't read from $ENV{'CONTENT_LENGTH'} twice like you are doing. The first time you read in the form data the buffer is emptied, so your data is in %fields, not %FORM. But you are using the CGI module, so all that reading from %ENV is not even necessary and should not be done. Use the CGI module to get all the form data into variables. Then do your email stuff.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top