Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl script with error

Status
Not open for further replies.

zakasa

Programmer
Nov 14, 2003
4
GB
I am a perl/cgi beginner and I have written a Perl script to email info entered into a form. I getting an error message which just say that there may be a scripting error. I am not sure what it is. Below is the script, please help.

#!/usr/bin/perl

%postInputs = readPostInput();
$dateCommand = "date";
$time = `$dateCommand`;
open (MAIL, "|/usr/sbin/sendmail -t") || return 0;

select (MAIL);
print << &quot;EOF&quot;;
To: sam\ @pterosaurtechnology.co.uk
From: $postInputs{ 'email'}
Subject: Questionaire Form

$time
Name: $postInputs{ 'name'}
Address1: $postInputs{ 'address1'}
Address2: $postInputs{ 'address2'}
Address3: $postInputs{ 'address3'}
Address4: $postInputs{ 'address4'}
DOB: $postInputs{ 'dob'}
Tel: $postInputs{ 'phone'}
Fax: $postInputs{ 'fax'}
Email: $postInputs{ 'email'}
Marital Status: $postInputs{ 'marital'}
No. of Children: $postInputs{ 'children'}
No of Dependants: $postInputs{ 'depend'}
Details of Dependants: $postInputs{ 'dependDetails'}
Close Relative in UK: $postInputs{ 'inUK'}
Close Relatives Overseas: $postInputs{ 'overseas'}
Qualifications: $postInputs{ 'qualifications'}
Present Employment: $postInputs{ 'employ'}
Present Salary: $postInputs{ 'salary'}
Spouses Employment: $postInputs{ 'spouseEmploy'}
Spouses Salary: $postInputs{ 'spouseSalary'}
Ancestry: $postInputs{ 'ancestry'}
Intentions: $postInputs{ 'intentions'}
Details: $postInputs{ 'previous'}


EOF
close(MAIL);
select (STDOUT);
printThankYou();

sub readPostInput(){
my (%searchField, $buffer, $pair, @pairs);
if ($ENV{ 'REQUEST_METHOD'} eq 'POST'){
read(STDIN, $buffer, $ENV{ 'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
$searchField { $name} = $value;
}
} return (%searchField);
}

sub printThankYou(){
print << &quot;EOF&quot;;
Content-Type: text/html

<head>
<title>Thank You</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;
charset=iso-8859-1&quot;>
</head>

<body bgcolor=&quot;#F7F7F7&quot;>
<div align=&quot;center&quot;>
<h2>THANK YOU</h2>
<h5>THANK YOU $postInputs{ 'name'} FOR SUBMITTING YOUR REQUEST FOR
INFORMATION.<br>
WE WILL GET BACK TO YOU AS SOON AS POSSIBLE.</h5>
</div>
</body>
</html>

EOF
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top