sulfericacid
Programmer
Hello,
I created a mail form which the source will be below. The only problem with the script is the redirection part at the end. It is supposed to redirect to thanks.html. What does it do? It prints 'Location: onto the browser screen.
Can someone tell me how to stop making it print and start redirecting?
Thanks.
-Acid
Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
######################################################################
##########################VARIABLES/MUST EDIT########################
use CGI qwstandard) ;
my $adminemail = param("adminemail"
my $webmastername = param("webmastername"
my $recipientemail = param("recipientemail" ;
my $visitorname = param("visitorname"
my $weburl = param("weburl"
my $subject = param("subject"
my $subject2 = param("subject2"
my $message = param("message"
my $autoresponse = param("autoresponse"
# Change with your email account
$adminemail='sulfericacid@qwest.net';
# Change to correct path of sendmail
$sendmail='/usr/sbin/sendmail';
# Homepage url, do not link to form, use your index. Ie. "$homepage='
# Change to enclosure. Ie. "Sincerly yours"
$thanks='Thank you for visiting our site, please come again!';
# Change to page redirect.
$redirect='# Change to autoresponse.
$autoresponse ='This is an autoresponse from SpyderSubmission. Your message was received. If you are awating a response, please allow upto 8 hours';
######################################################################
#######################FORM PARSING/DON'T EDIT########################
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
if ($recipientemail) {
unless ($recipientemail =~ /\w+@\w+.\w+/) {
print "<H1><CENTER><FONT COLOR=RED>OOPS!</FONT></CENTER></H1>\n\n\n\n";
print "Sorry, the email address <font color=red>$recipientemail </font> is invalid. Please try again\n";
exit;
}
}
######################################################################
#######################EMAIL TO VISITOR/DON'T EDIT######################
open(MAIL,"|$sendmail -t"
print MAIL "To: $recipientemail\n";
print MAIL "From: $adminemail\n";
print MAIL "Subject: $subject\n";
print MAIL "Greetings, $visitorname\n\n";
print MAIL "$autoresponse\n\n";
print MAIL "You wrote-$message\n\n";
print MAIL "$thanks\n";
print MAIL "$webmastername\n";
print MAIL "mailto:$adminemail\n";
print MAIL "$homepage\n";
close(MAIL);
######################################################################
#######################EMAIL TO ADMIN/DON'T EDIT#######################
open(MAIL,"|$sendmail -t"
print MAIL "To: $adminemail\n";
print MAIL "From: $recipientemail\n";
print MAIL "Subject: $subject2\n";
print MAIL "Name- $visitorname\n";
print MAIL "Email- $recipientemail\n";
print MAIL "URL- $weburl\n";
print MAIL "Message- $message\n";
close(MAIL);
######################################################################
##########################REDIRECT/DON'T EDIT#########################
#Redirect to the Thanks page.
print "Location: $redirect";
exit;
I created a mail form which the source will be below. The only problem with the script is the redirection part at the end. It is supposed to redirect to thanks.html. What does it do? It prints 'Location: onto the browser screen.
Can someone tell me how to stop making it print and start redirecting?
Thanks.
-Acid
Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
######################################################################
##########################VARIABLES/MUST EDIT########################
use CGI qwstandard) ;
my $adminemail = param("adminemail"
my $webmastername = param("webmastername"
my $recipientemail = param("recipientemail" ;
my $visitorname = param("visitorname"
my $weburl = param("weburl"
my $subject = param("subject"
my $subject2 = param("subject2"
my $message = param("message"
my $autoresponse = param("autoresponse"
# Change with your email account
$adminemail='sulfericacid@qwest.net';
# Change to correct path of sendmail
$sendmail='/usr/sbin/sendmail';
# Homepage url, do not link to form, use your index. Ie. "$homepage='
# Change to enclosure. Ie. "Sincerly yours"
$thanks='Thank you for visiting our site, please come again!';
# Change to page redirect.
$redirect='# Change to autoresponse.
$autoresponse ='This is an autoresponse from SpyderSubmission. Your message was received. If you are awating a response, please allow upto 8 hours';
######################################################################
#######################FORM PARSING/DON'T EDIT########################
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
if ($recipientemail) {
unless ($recipientemail =~ /\w+@\w+.\w+/) {
print "<H1><CENTER><FONT COLOR=RED>OOPS!</FONT></CENTER></H1>\n\n\n\n";
print "Sorry, the email address <font color=red>$recipientemail </font> is invalid. Please try again\n";
exit;
}
}
######################################################################
#######################EMAIL TO VISITOR/DON'T EDIT######################
open(MAIL,"|$sendmail -t"
print MAIL "To: $recipientemail\n";
print MAIL "From: $adminemail\n";
print MAIL "Subject: $subject\n";
print MAIL "Greetings, $visitorname\n\n";
print MAIL "$autoresponse\n\n";
print MAIL "You wrote-$message\n\n";
print MAIL "$thanks\n";
print MAIL "$webmastername\n";
print MAIL "mailto:$adminemail\n";
print MAIL "$homepage\n";
close(MAIL);
######################################################################
#######################EMAIL TO ADMIN/DON'T EDIT#######################
open(MAIL,"|$sendmail -t"
print MAIL "To: $adminemail\n";
print MAIL "From: $recipientemail\n";
print MAIL "Subject: $subject2\n";
print MAIL "Name- $visitorname\n";
print MAIL "Email- $recipientemail\n";
print MAIL "URL- $weburl\n";
print MAIL "Message- $message\n";
close(MAIL);
######################################################################
##########################REDIRECT/DON'T EDIT#########################
#Redirect to the Thanks page.
print "Location: $redirect";
exit;