Hi,
I'm running my perl script on a apache unix server, with windows 2000 o/s, I believe the perl script works, I'm calling the form form html/form/supportform.html, the cgi-bin is at the same level as html folder is. I can't get it to run.
Could you please look at my script.
Thanks
Shawn
#!/usr/bin/perl
$mail_prog = '/usr/sbin/sendmail -t';
# recieving info e-mail address
$contact_mail = "shawnm\@komnetworks.com";
@all;
$subject = "Online Support Help Form";
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";
}
}
}
return 1;
}
sub AssignValues {
if ($field{'NEEDS_TECHNICAL_SUPPORT_HELP'} eq ""
{
$field{'NEEDS_TECHNICAL_SUPPORT_HELP'} = "YES"
}
else
{
$field{'NEEDS_TECHNICAL_SUPPORT_HELP'} = "NO"
}
@ProductLicense = ("Product License ", $field{'ProductLicense'});
@all = (@all, @ProductLicense);
@Organization = ("Organization ", $field{'Organization'});
@all = (@all, @Organization);
@ContactName = ("Contact Name ", $field{'ContactName'});
@all = (@all, @ContactName);
@Phone = ("Phone ", $field{'Phone'});
@all = (@all, @Phone);
@EmailAddress = ("Email Address ", $field{'EmailAddress'});
@all = (@all, @AddressEmail);
@RequestType = ("Request Type ", $field{'RequestType'});
@all = (@all, @RequestType);
@ProductName = ("Product Name ", $field{'ProductName'});
@all = (@all, @ProductName);
@Subject = ("Subject ", $field{'Subject'});
@all = (@all, @Subject);
@Severity = ("Severity ", $field{'Severity'});
@all = (@all, @Severity);
@DescriptionofRequest = ("Description of Request ", $field{'DescriptionofRequest'});
@all = (@all, @DescriptionofRequest);
@UploadaFile = ("Upload File ", $field{'UploadaFile'});
@all = (@all, @UploadaFile);
@AdditionalNotes = ("Additional Notes ", $field{'AdditionalNotes'});
@all = (@all, @AdditionalNotes);
sub ThankYou {
print "Content-type: text/html\n\n";
$html_template = "/ open(TEMPLATE,$html_template);
while(<TEMPLATE>) {
$Line = $_;
foreach $name (keys %field) {
$Line =~ s/{$name}/$field{$name}/g;
}
print $Line;
}
close(TEMPLATE);
}
sub SendMailTo
{
open(MAIL,"|$mail_prog"
print MAIL "To: $contact_mail\n";
print MAIL "From: $field{'Email'}\n";
print MAIL "Subject: $subject\n";
print MAIL "This user was interested in ON-Line Support Help\n\n";
$counter = 0;
foreach $val (@all)
{
if ($counter == 2)
{
$counter = 0;
print MAIL "_________________________________________________\n";
}
if ($val eq "" {
print MAIL "Not Submitted \n";
}
else {
print MAIL "$val \n";
}
$counter++;
}
print MAIL "\n\n";
close (MAIL);
}
sub SendMailFrom
{
open(MAIL,"|$mail_prog"
print MAIL "To: $field{'Email'}\n";
print MAIL "From: $contact_mail\n";
print MAIL "Subject: $subject\n";
$mail_template = "/ print MAIL "Dear $field{'FirstName'}, \n";
open(TEMPLATE,$mail_template);
while(<TEMPLATE>) {
$Le = $_;
print MAIL $Le;
}
print MAIL "\n\n";
close (MAIL);
}
}
&GetFormInput;
&AssignValues;
&ThankYou;
&SendMailTo;
&SendMailFrom;
I'm running my perl script on a apache unix server, with windows 2000 o/s, I believe the perl script works, I'm calling the form form html/form/supportform.html, the cgi-bin is at the same level as html folder is. I can't get it to run.
Could you please look at my script.
Thanks
Shawn
#!/usr/bin/perl
$mail_prog = '/usr/sbin/sendmail -t';
# recieving info e-mail address
$contact_mail = "shawnm\@komnetworks.com";
@all;
$subject = "Online Support Help Form";
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";
}
}
}
return 1;
}
sub AssignValues {
if ($field{'NEEDS_TECHNICAL_SUPPORT_HELP'} eq ""
{
$field{'NEEDS_TECHNICAL_SUPPORT_HELP'} = "YES"
}
else
{
$field{'NEEDS_TECHNICAL_SUPPORT_HELP'} = "NO"
}
@ProductLicense = ("Product License ", $field{'ProductLicense'});
@all = (@all, @ProductLicense);
@Organization = ("Organization ", $field{'Organization'});
@all = (@all, @Organization);
@ContactName = ("Contact Name ", $field{'ContactName'});
@all = (@all, @ContactName);
@Phone = ("Phone ", $field{'Phone'});
@all = (@all, @Phone);
@EmailAddress = ("Email Address ", $field{'EmailAddress'});
@all = (@all, @AddressEmail);
@RequestType = ("Request Type ", $field{'RequestType'});
@all = (@all, @RequestType);
@ProductName = ("Product Name ", $field{'ProductName'});
@all = (@all, @ProductName);
@Subject = ("Subject ", $field{'Subject'});
@all = (@all, @Subject);
@Severity = ("Severity ", $field{'Severity'});
@all = (@all, @Severity);
@DescriptionofRequest = ("Description of Request ", $field{'DescriptionofRequest'});
@all = (@all, @DescriptionofRequest);
@UploadaFile = ("Upload File ", $field{'UploadaFile'});
@all = (@all, @UploadaFile);
@AdditionalNotes = ("Additional Notes ", $field{'AdditionalNotes'});
@all = (@all, @AdditionalNotes);
sub ThankYou {
print "Content-type: text/html\n\n";
$html_template = "/ open(TEMPLATE,$html_template);
while(<TEMPLATE>) {
$Line = $_;
foreach $name (keys %field) {
$Line =~ s/{$name}/$field{$name}/g;
}
print $Line;
}
close(TEMPLATE);
}
sub SendMailTo
{
open(MAIL,"|$mail_prog"
print MAIL "To: $contact_mail\n";
print MAIL "From: $field{'Email'}\n";
print MAIL "Subject: $subject\n";
print MAIL "This user was interested in ON-Line Support Help\n\n";
$counter = 0;
foreach $val (@all)
{
if ($counter == 2)
{
$counter = 0;
print MAIL "_________________________________________________\n";
}
if ($val eq "" {
print MAIL "Not Submitted \n";
}
else {
print MAIL "$val \n";
}
$counter++;
}
print MAIL "\n\n";
close (MAIL);
}
sub SendMailFrom
{
open(MAIL,"|$mail_prog"
print MAIL "To: $field{'Email'}\n";
print MAIL "From: $contact_mail\n";
print MAIL "Subject: $subject\n";
$mail_template = "/ print MAIL "Dear $field{'FirstName'}, \n";
open(TEMPLATE,$mail_template);
while(<TEMPLATE>) {
$Le = $_;
print MAIL $Le;
}
print MAIL "\n\n";
close (MAIL);
}
}
&GetFormInput;
&AssignValues;
&ThankYou;
&SendMailTo;
&SendMailFrom;