spewn
Programmer
- May 7, 2001
- 1,034
i got it able to accept just ".cgi" as an extension.
question: (hope you dno't mind)
i set up a folder called "perl_scripts" on my desktop. i have a file called input.html that looks like this...
*******
--- input.html
<html><head></head>
<body bgcolor="#ffffff" link="#808080">
<p align="center"> </p><div align="left">
<form action="cgi-bin/readInput.cgi" method="POST">
<blockquote>
<table border="0">
<tr>
<td align="right"><em>Name</td></td>
<td><input type="text" size=35" name="Contact_FullName"></td>
</tr>
<tr>
<td align="right"><em>Title</em></td>
<td><input type="text" size="35" name="Contact_Organization"></td>
</tr>
<tr>
<td align="right"><em>Street Address</em></td>
<td><input type="text" size="35" name="Contact_StreetAddress"></td>
</tr>
<tr>
<td align="right"><em>City</em></td>
<td><input type="text" size="35" name="Contact_City"></td>
</tr>
<tr>
<td align="right"><em>State/Province</td></td>
<td><input type="text" size=35" name="Contact_State"></td>
</tr>
<tr>
<td align="right"><em>Zip/Postal Code</em></td>
<td><input type="text" size="12" maxlength="12" name="Contact_ZipCode"></td>
</tr>
<tr>
<td align="right"><em>Country</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_Country"></td>
</tr>
<tr>
<td align="right"><em>Work Phone</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_WorkPhone"></td>
</tr>
<tr>
<td align="right"><em>Home Phone</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_HomePhone"></td>
</tr>
<tr>
<td align="right"><em>FAX</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_FAX"></td>
</tr>
<tr>
<td align="right"><em>E-mail</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_Email"></td>
</tr>
<tr>
<td align="right"><em>URL</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_URL"></td>
</tr>
</table>
</blockquote>
<p>What are your requirements? Include dates, # of people, special needs, etc.</p>
<blockquote>
<p><textarea name="comments" rows="5" col="35">
</textarea>
</p>
</blockquote>
<p>Please <input type="submit" value="submit this form"> when finished or <input type="reset" value="clear it"> to start over.</p>
</form>
</body>
</html>
*******
inside the folder i set up a sub folder called 'cgi-bin' in which i put the following script...
*******
--- readInput.cgi
#!/usr/bin/perl
%postInputs = readPostInput();
$dateCommand = "date";
open (MAIL, "|/usr/sbin/sendmail -t"
|| return 0;
select (MAIL);
print << "EOF";
To: g\@one-degree.com
From: $postInputs{'Contact_Email'}
Subject: $postInputs{'Organization'} Information Requested
$time
$postInputs{'Organization'} Information Requested
Name: $postInputs{'Contact_FullName'}
Email: $postInputs{'Contact_Email'}
Street Address: $postInputs{'Contact_StreetAddress'}
Street Address (cont.): $postInputs{'Contact_Address2'}
City: $postInputs{'Contact_City'}
State: $postInputs{'Contact_State'}
Zip: $postInputs{'Contact_ZipCode'}
Work Phone: $postInputs{'Contact_WorkPhone'}
Home Phone: $postInputs{'Contact_HomePhone'}
FAX: $postInputs{'Contact_FAX'}
Email: $postInputs{'Contact_Email'}
Comments: $postInputs{'comments'}
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("C", hex($1))/eg;
$name = =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$searchField{ $name} = $value;
}
}
return (%searchField);
}
sub printThankYou(){
print << "EOF";
Content-Type: text/html
<head>
<title>THANK YOU FOR YOUR REQUEST</title>
</head>
<body>
<table cellspacing=2 cellpadding=2 border=0 width=600>
<tr><th><br>
<center>
<font size=+3><b>Thank You $postInputs{'Contact_FullName'}</b></font>
</center><br><br>
<center><b><font size=+1><p>For submitting your information. We will get back to you shortly.</p>
</b>
</font>
<center>
</th></table>
</body>
</html>
EOF
}
*********
i have no idea of this, just wrote it out of the book and would like to decipher...best way i learn! but the problem, it doesn't do anything. now, i have the same set up on my server live on the web, and at least there, i get an error message that reads...
syntax error at readInput.cgi line 43, near "= =~"
Execution of readInput.cgi aborted due to compilation errors.
can you trouble shoot? i installed perl win32 and set all the defaults. is the #!/usr... in the beginning pointing to perl on my system? perl is at c:/windows/perl according to my file tree...
- g
question: (hope you dno't mind)
i set up a folder called "perl_scripts" on my desktop. i have a file called input.html that looks like this...
*******
--- input.html
<html><head></head>
<body bgcolor="#ffffff" link="#808080">
<p align="center"> </p><div align="left">
<form action="cgi-bin/readInput.cgi" method="POST">
<blockquote>
<table border="0">
<tr>
<td align="right"><em>Name</td></td>
<td><input type="text" size=35" name="Contact_FullName"></td>
</tr>
<tr>
<td align="right"><em>Title</em></td>
<td><input type="text" size="35" name="Contact_Organization"></td>
</tr>
<tr>
<td align="right"><em>Street Address</em></td>
<td><input type="text" size="35" name="Contact_StreetAddress"></td>
</tr>
<tr>
<td align="right"><em>City</em></td>
<td><input type="text" size="35" name="Contact_City"></td>
</tr>
<tr>
<td align="right"><em>State/Province</td></td>
<td><input type="text" size=35" name="Contact_State"></td>
</tr>
<tr>
<td align="right"><em>Zip/Postal Code</em></td>
<td><input type="text" size="12" maxlength="12" name="Contact_ZipCode"></td>
</tr>
<tr>
<td align="right"><em>Country</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_Country"></td>
</tr>
<tr>
<td align="right"><em>Work Phone</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_WorkPhone"></td>
</tr>
<tr>
<td align="right"><em>Home Phone</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_HomePhone"></td>
</tr>
<tr>
<td align="right"><em>FAX</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_FAX"></td>
</tr>
<tr>
<td align="right"><em>E-mail</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_Email"></td>
</tr>
<tr>
<td align="right"><em>URL</em></td>
<td><input type="text" size="25" maxlength="25" name="Contact_URL"></td>
</tr>
</table>
</blockquote>
<p>What are your requirements? Include dates, # of people, special needs, etc.</p>
<blockquote>
<p><textarea name="comments" rows="5" col="35">
</textarea>
</p>
</blockquote>
<p>Please <input type="submit" value="submit this form"> when finished or <input type="reset" value="clear it"> to start over.</p>
</form>
</body>
</html>
*******
inside the folder i set up a sub folder called 'cgi-bin' in which i put the following script...
*******
--- readInput.cgi
#!/usr/bin/perl
%postInputs = readPostInput();
$dateCommand = "date";
open (MAIL, "|/usr/sbin/sendmail -t"
select (MAIL);
print << "EOF";
To: g\@one-degree.com
From: $postInputs{'Contact_Email'}
Subject: $postInputs{'Organization'} Information Requested
$time
$postInputs{'Organization'} Information Requested
Name: $postInputs{'Contact_FullName'}
Email: $postInputs{'Contact_Email'}
Street Address: $postInputs{'Contact_StreetAddress'}
Street Address (cont.): $postInputs{'Contact_Address2'}
City: $postInputs{'Contact_City'}
State: $postInputs{'Contact_State'}
Zip: $postInputs{'Contact_ZipCode'}
Work Phone: $postInputs{'Contact_WorkPhone'}
Home Phone: $postInputs{'Contact_HomePhone'}
FAX: $postInputs{'Contact_FAX'}
Email: $postInputs{'Contact_Email'}
Comments: $postInputs{'comments'}
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("C", hex($1))/eg;
$name = =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$searchField{ $name} = $value;
}
}
return (%searchField);
}
sub printThankYou(){
print << "EOF";
Content-Type: text/html
<head>
<title>THANK YOU FOR YOUR REQUEST</title>
</head>
<body>
<table cellspacing=2 cellpadding=2 border=0 width=600>
<tr><th><br>
<center>
<font size=+3><b>Thank You $postInputs{'Contact_FullName'}</b></font>
</center><br><br>
<center><b><font size=+1><p>For submitting your information. We will get back to you shortly.</p>
</b>
</font>
<center>
</th></table>
</body>
</html>
EOF
}
*********
i have no idea of this, just wrote it out of the book and would like to decipher...best way i learn! but the problem, it doesn't do anything. now, i have the same set up on my server live on the web, and at least there, i get an error message that reads...
syntax error at readInput.cgi line 43, near "= =~"
Execution of readInput.cgi aborted due to compilation errors.
can you trouble shoot? i installed perl win32 and set all the defaults. is the #!/usr... in the beginning pointing to perl on my system? perl is at c:/windows/perl according to my file tree...
- g