shayta
05-07-2003, 03:05 PM
So here's what I'm trying to do...
I want to have a input box, where the visitor can enter their email address, and then a pre-made email will be sent to them AND their email address will be saved to a text file.
So far here is what I have...
Here's what's in the HTML page...
<form method="POST" action="/cgi-bin/emails.pl">
e-mail : <input name="email" size="44" maxlength="100">
<input type="submit" value="Submit" id="submit1" name="submit1">
Here's what's in emails.pl
#!/usr/bin/perl
#emails.pl
print "Content-type:text/html\n\n"; #Content Header
#Show errors in web browser
use CGI::Carp qw(fatalsToBrowser);
# Get the input
read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
$buffer =~ tr/+/ /; # Un-Webify plus signs and %-encoding
$buffer =~ s/\r/ /g;
$buffer =~ s/\n/ /g;
@pairs = split(/&/,$buffer); # Split the name-value pairs
foreach $pair(@pairs){
($key,$value)=split(/=/,$pair);
$formdata{$key}.="$value";
}
$email=$formdata{'email'}; # Variables
$emailsToFile=">>$ENV{'DOCUMENT_ROOT'}/www/emails.txt";
# Open State Link File to Output for appending
open(INFO, "$emailsToFile");
print INFO "$email, ";
close (INFO);
print <<End_of_Doc;
<html>
<head><title>Email Confirmation</title></head>
<body>
<form method="POST" action="/cgi/formmail">
<input type=hidden name="recipient" value="$email">
<input type=hidden name="subject" value="Here's your the information you requested...">
Thank you!<BR>
Your email has been sent to $email.<BR>
</body>
</html>
End_of_Doc
Basically what I tried doing here is capturing their email address in the emails.pl file, which would then generate a list of emails (emails.txt) but then also utilize the $email address using formmail to send them an email. This isn't working. Does anyone have any ideas?
I would like to be able to do what I'm doing by using two actions in one form, but I know that isn't possible.
I want to have a input box, where the visitor can enter their email address, and then a pre-made email will be sent to them AND their email address will be saved to a text file.
So far here is what I have...
Here's what's in the HTML page...
<form method="POST" action="/cgi-bin/emails.pl">
e-mail : <input name="email" size="44" maxlength="100">
<input type="submit" value="Submit" id="submit1" name="submit1">
Here's what's in emails.pl
#!/usr/bin/perl
#emails.pl
print "Content-type:text/html\n\n"; #Content Header
#Show errors in web browser
use CGI::Carp qw(fatalsToBrowser);
# Get the input
read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
$buffer =~ tr/+/ /; # Un-Webify plus signs and %-encoding
$buffer =~ s/\r/ /g;
$buffer =~ s/\n/ /g;
@pairs = split(/&/,$buffer); # Split the name-value pairs
foreach $pair(@pairs){
($key,$value)=split(/=/,$pair);
$formdata{$key}.="$value";
}
$email=$formdata{'email'}; # Variables
$emailsToFile=">>$ENV{'DOCUMENT_ROOT'}/www/emails.txt";
# Open State Link File to Output for appending
open(INFO, "$emailsToFile");
print INFO "$email, ";
close (INFO);
print <<End_of_Doc;
<html>
<head><title>Email Confirmation</title></head>
<body>
<form method="POST" action="/cgi/formmail">
<input type=hidden name="recipient" value="$email">
<input type=hidden name="subject" value="Here's your the information you requested...">
Thank you!<BR>
Your email has been sent to $email.<BR>
</body>
</html>
End_of_Doc
Basically what I tried doing here is capturing their email address in the emails.pl file, which would then generate a list of emails (emails.txt) but then also utilize the $email address using formmail to send them an email. This isn't working. Does anyone have any ideas?
I would like to be able to do what I'm doing by using two actions in one form, but I know that isn't possible.