Flite
08-03-2004, 08:54 PM
This script is working fine, but it wont pass the 'realname' variable onto my mailing software.
So when I fill out the form, I receive the autoresponder message like I should, but the subject has the default name "Friend" instead of the name I filled out on the Webform ie:
Friend, here is you free report
instead of
Jason, here is your free report
How can I change this script so that it passes on the name variable?
Thanks for any help
-------------
#!/usr/bin/perl
$mail_prog = '/usr/sbin/sendmail' ;
&GetFormInput;
$realname = $field{'realname'} ;
$email = $field{'email'} ;
$subject = $field{'subject'} ;
$recipient = $field{'recipient'} ;
$redirect = $field{'redirect'} ;
$required = $field{'required'} ;
$message = "" ;
$found_err = "" ;
$errmsg = "<p>Please enter a valid email address</p>\n" ;
if (($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/) || ($email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z0-9]+)(\]?)$/)) {
$message = $message.$errmsg ;
$found_err = 1 ; }
if ($found_err) {
&PrintError; }
$recip = "course\@sixweekstosuccess.com" ;
$frm_ = "$email" ;
$sbj_ = "course" ;
$hd_ = $recip.$frm_.$sbj ;
if (($hd =~ /(\n|\r)/m) || ($recip =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/) || ($recip !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z0-9]+)(\]?)$/)) {
print "Fatal Error - Invalid email" ;
exit 0;
}
open (MAIL, "|$mail_prog -t");
print MAIL "To: $recip\n";
print MAIL "Reply-to: $frm_\n";
print MAIL "From: $frm_\n";
print MAIL "Subject: $sbj_\n";
print MAIL "\n\n";
print MAIL "".$realname."\n" ;
print MAIL "\n\n";
close (MAIL);
print "Location: http://www.sixweekstosuccess.com\nURI: http://www.sixweekstosuccess.com\n\n" ;
sub PrintError {
print "Content-type: text/html\n\n";
print $message ;
print "<p> Please use your browser's Back button to return to the form. </p>" ;
exit 0 ;
return 1 ;
}
sub GetFormInput {
(*fval) = @_ if @_ ;
local ($buf);
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
}
else {
$buf=$ENV{'QUERY_STRING'};
}
if ($buf eq "") {
return 0 ;
}
else {
@fval=split(/&/,$buf);
foreach $i (0 .. $#fval){
($name,$val)=split (/=/,$fval[$i],2);
$val=~tr/+/ /;
$val=~ s/%(..)/pack("c",hex($1))/ge;
$name=~tr/+/ /;
$name=~ s/%(..)/pack("c",hex($1))/ge;
if (!defined($field{$name})) {
$field{$name}=$val;
}
else {
$field{$name} .= ",$val";
#if you want multi-selects to goto into an array change to:
#$field{$name} .= "\0$val";
}
}
}
return 1;
}
-------------------------------------------------------------------
So when I fill out the form, I receive the autoresponder message like I should, but the subject has the default name "Friend" instead of the name I filled out on the Webform ie:
Friend, here is you free report
instead of
Jason, here is your free report
How can I change this script so that it passes on the name variable?
Thanks for any help
-------------
#!/usr/bin/perl
$mail_prog = '/usr/sbin/sendmail' ;
&GetFormInput;
$realname = $field{'realname'} ;
$email = $field{'email'} ;
$subject = $field{'subject'} ;
$recipient = $field{'recipient'} ;
$redirect = $field{'redirect'} ;
$required = $field{'required'} ;
$message = "" ;
$found_err = "" ;
$errmsg = "<p>Please enter a valid email address</p>\n" ;
if (($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/) || ($email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z0-9]+)(\]?)$/)) {
$message = $message.$errmsg ;
$found_err = 1 ; }
if ($found_err) {
&PrintError; }
$recip = "course\@sixweekstosuccess.com" ;
$frm_ = "$email" ;
$sbj_ = "course" ;
$hd_ = $recip.$frm_.$sbj ;
if (($hd =~ /(\n|\r)/m) || ($recip =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/) || ($recip !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z0-9]+)(\]?)$/)) {
print "Fatal Error - Invalid email" ;
exit 0;
}
open (MAIL, "|$mail_prog -t");
print MAIL "To: $recip\n";
print MAIL "Reply-to: $frm_\n";
print MAIL "From: $frm_\n";
print MAIL "Subject: $sbj_\n";
print MAIL "\n\n";
print MAIL "".$realname."\n" ;
print MAIL "\n\n";
close (MAIL);
print "Location: http://www.sixweekstosuccess.com\nURI: http://www.sixweekstosuccess.com\n\n" ;
sub PrintError {
print "Content-type: text/html\n\n";
print $message ;
print "<p> Please use your browser's Back button to return to the form. </p>" ;
exit 0 ;
return 1 ;
}
sub GetFormInput {
(*fval) = @_ if @_ ;
local ($buf);
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
}
else {
$buf=$ENV{'QUERY_STRING'};
}
if ($buf eq "") {
return 0 ;
}
else {
@fval=split(/&/,$buf);
foreach $i (0 .. $#fval){
($name,$val)=split (/=/,$fval[$i],2);
$val=~tr/+/ /;
$val=~ s/%(..)/pack("c",hex($1))/ge;
$name=~tr/+/ /;
$name=~ s/%(..)/pack("c",hex($1))/ge;
if (!defined($field{$name})) {
$field{$name}=$val;
}
else {
$field{$name} .= ",$val";
#if you want multi-selects to goto into an array change to:
#$field{$name} .= "\0$val";
}
}
}
return 1;
}
-------------------------------------------------------------------