j_uu
10-27-2002, 10:09 PM
(PLEASE LET ME KNOW IF THIS ALTERATION IS CORRECT & WILL WORK ! :thumbsup: )
right, this is a long one !
my current submit form at :
http://www.handfinishedframes.com/contactus.html
uses this cgi code (it works fine) :
#!/usr/bin/perl5
# Read in form data
&parse_form;
&check_fields_ok;
&mail_admin;
sub mail_admin
{
#$to = "$in{'sendto'}";
$to = 'info@handfinishedframes.com';
$from = "$in{'email'}";
$subject = 'Hand Finished Frames Information Request Form';
print "Location: http://www.handfinishedframes.com/success.html \n\n";
open (MAIL, "|/usr/sbin/sendmail -t -n");
print MAIL <<ENDOFMAIL;
To: $to
From: $from
Subject: $subject
Name: $in{'name'}
Last Name: $in{'lastname'}
Title: $in{'title'}
Company: $in{'company'}
VAT NO (UK/EEC only): $in{'vat'}
Address: $in{'address'}
Town / City: $in{'town'}
County / state: $in{'county'}
Post / Zip Code: $in{'zip'}
Country: $in{'country'}
Telephone: $in{'telephone'}
Fax: $in{'fax'}
Email: $in{'email'}
Website: $in{'website'}
Comments: $in{'comments'}
ENDOFMAIL
close (MAIL);
#print "Location: http://www.handfinishedframes.com/success.html \n\n";
#print "Content-type: text/html\n\n";
#print "This is a test!";
exit;
}
sub check_fields_ok
{
if ($in{'name'} eq "" || $in{'email'} eq "")
{
print "Location: http://$ENV{'HTTP_HOST'}/error.html \n\n";
exit;
}
}
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@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;
$in{$name} = $value;
}
}
my new submit form will be :
http://www.handfinishedframes.com/contactus-new.html
now, am i right in thinking that adding this new piece of code :
Newsletter: $in{'newsletter'}
Newsletter Format: $in{'newsletter-format'}
to the existing cgi script will work with the new checkboxes and radio buttons ?
new altered cgi script :
#!/usr/bin/perl5
# Read in form data
&parse_form;
&check_fields_ok;
&mail_admin;
sub mail_admin
{
#$to = "$in{'sendto'}";
$to = 'info@handfinishedframes.com';
$from = "$in{'email'}";
$subject = 'Hand Finished Frames Information Request Form';
print "Location: http://www.handfinishedframes.com/success.html \n\n";
open (MAIL, "|/usr/sbin/sendmail -t -n");
print MAIL <<ENDOFMAIL;
To: $to
From: $from
Subject: $subject
Name: $in{'name'}
Last Name: $in{'lastname'}
Title: $in{'title'}
Company: $in{'company'}
Address: $in{'address'}
Town / City: $in{'town'}
County / state: $in{'county'}
Post / Zip Code: $in{'zip'}
Country: $in{'country'}
Telephone: $in{'telephone'}
Fax: $in{'fax'}
Email: $in{'email'}
Website: $in{'website'}
VAT NO (UK/EEC only): $in{'vat'}
Newsletter: $in{'newsletter'}
Newsletter Format: $in{'newsletter-format'}
Comments: $in{'comments'}
ENDOFMAIL
close (MAIL);
#print "Location: http://www.handfinishedframes.com/success.html \n\n";
#print "Content-type: text/html\n\n";
#print "This is a test!";
exit;
}
sub check_fields_ok
{
if ($in{'name'} eq "" || $in{'email'} eq "")
{
print "Location: http://$ENV{'HTTP_HOST'}/error.html \n\n";
exit;
}
}
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@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;
$in{$name} = $value;
}
}
if i am wrong, please let me know what needs to be added to make it work.
also, how long should it take to get this working on a server ?
thankyou very very much
jon
right, this is a long one !
my current submit form at :
http://www.handfinishedframes.com/contactus.html
uses this cgi code (it works fine) :
#!/usr/bin/perl5
# Read in form data
&parse_form;
&check_fields_ok;
&mail_admin;
sub mail_admin
{
#$to = "$in{'sendto'}";
$to = 'info@handfinishedframes.com';
$from = "$in{'email'}";
$subject = 'Hand Finished Frames Information Request Form';
print "Location: http://www.handfinishedframes.com/success.html \n\n";
open (MAIL, "|/usr/sbin/sendmail -t -n");
print MAIL <<ENDOFMAIL;
To: $to
From: $from
Subject: $subject
Name: $in{'name'}
Last Name: $in{'lastname'}
Title: $in{'title'}
Company: $in{'company'}
VAT NO (UK/EEC only): $in{'vat'}
Address: $in{'address'}
Town / City: $in{'town'}
County / state: $in{'county'}
Post / Zip Code: $in{'zip'}
Country: $in{'country'}
Telephone: $in{'telephone'}
Fax: $in{'fax'}
Email: $in{'email'}
Website: $in{'website'}
Comments: $in{'comments'}
ENDOFMAIL
close (MAIL);
#print "Location: http://www.handfinishedframes.com/success.html \n\n";
#print "Content-type: text/html\n\n";
#print "This is a test!";
exit;
}
sub check_fields_ok
{
if ($in{'name'} eq "" || $in{'email'} eq "")
{
print "Location: http://$ENV{'HTTP_HOST'}/error.html \n\n";
exit;
}
}
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@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;
$in{$name} = $value;
}
}
my new submit form will be :
http://www.handfinishedframes.com/contactus-new.html
now, am i right in thinking that adding this new piece of code :
Newsletter: $in{'newsletter'}
Newsletter Format: $in{'newsletter-format'}
to the existing cgi script will work with the new checkboxes and radio buttons ?
new altered cgi script :
#!/usr/bin/perl5
# Read in form data
&parse_form;
&check_fields_ok;
&mail_admin;
sub mail_admin
{
#$to = "$in{'sendto'}";
$to = 'info@handfinishedframes.com';
$from = "$in{'email'}";
$subject = 'Hand Finished Frames Information Request Form';
print "Location: http://www.handfinishedframes.com/success.html \n\n";
open (MAIL, "|/usr/sbin/sendmail -t -n");
print MAIL <<ENDOFMAIL;
To: $to
From: $from
Subject: $subject
Name: $in{'name'}
Last Name: $in{'lastname'}
Title: $in{'title'}
Company: $in{'company'}
Address: $in{'address'}
Town / City: $in{'town'}
County / state: $in{'county'}
Post / Zip Code: $in{'zip'}
Country: $in{'country'}
Telephone: $in{'telephone'}
Fax: $in{'fax'}
Email: $in{'email'}
Website: $in{'website'}
VAT NO (UK/EEC only): $in{'vat'}
Newsletter: $in{'newsletter'}
Newsletter Format: $in{'newsletter-format'}
Comments: $in{'comments'}
ENDOFMAIL
close (MAIL);
#print "Location: http://www.handfinishedframes.com/success.html \n\n";
#print "Content-type: text/html\n\n";
#print "This is a test!";
exit;
}
sub check_fields_ok
{
if ($in{'name'} eq "" || $in{'email'} eq "")
{
print "Location: http://$ENV{'HTTP_HOST'}/error.html \n\n";
exit;
}
}
sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@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;
$in{$name} = $value;
}
}
if i am wrong, please let me know what needs to be added to make it work.
also, how long should it take to get this working on a server ?
thankyou very very much
jon