Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Premature end of script headers

Reply
Thread Tools

Premature end of script headers

 
 
Wayne Deleersnyder
Guest
Posts: n/a
 
      11-21-2003
Hi,

I'm a newbie at Perl and CGI and hoping someone can point me in the
right direction.

Recently I've been going through an older book I have on CGI programming
to get a start. Most of it involves using Perl 5 though. The book is
"Sams Teach Yourself CGI Programming In A Week", by Rafe Colburn. Until
recently, things were going smoothly. Then, depending on the script
that I'd copy from the book, I'd start getting "Premature end of script
headers" errors in my error_log.

The script that I'm trying to get working right now is used for session
tracking. Simply passing information from an HTML page to the script,
which embeds the information in hidden fields.

But everytime I run the script I get a 500 Internal Server Error and the
error_log says: "Premature end of script headers: doform.cgi, referer:
http://testsite/form1.html"

I'm not sure if this is because of some configuration on my server or
because I'm using the CGI.pm module. This error only pops up when I
have "use CGI;" in the script.

Here's the script and HTML form if it'll help:

This is the form1.html page:
<html>
<head>
<title>Order Form</title>
</head>

<body>
<h1 alighn=center>Order Form, Part 1</h1>

<div align=center>
<form action="/cgi-bin/doform.cgi" method="post">
<table border=0>
<tr>
<td align=right>Name:</td>
<td><input type=text size=40 maxsize=80 name="address"></td>
</tr>
<tr>
<td align=right>Phone Number:</td>
<td><input type=text size=20 maxsize=20 name="phone"></td>
</tr>
<tr>
<td align=right>Email Address:</td>
<td><input type=text size=40 maxsize=40 name="email"></td>
</tr>
<tr>
<td><br></td>
<td><input type=submit value="Place Order"></td>
</tr>
</table>
</form>
</div>
</body>
</html>



This is the doform.cgi script.
#!/usr/bin/perl
use CGI;
$input = new CGI;

# The param() method contains all of the data gathered
# from the form, stored undre the name of each field.
# All this CGI script hass to do is store that data in the
# new form that it creates.

print $input->header;

print "<html>\n<head>\n<title>Order Form, Part 2</title>\n</head>\n";
print "<body>\n";
print "<h1 align=cneter>Order Form, Part 2</h1>\n";
print "<form action=\"cgi-bin\"doform2.cgi\" method=\"post\"\n";
print "<div align=center>";

print "<input type=hidden name=\"name\" value=\"";
print $input->param('name'), "\">\n";
print "<input type=hidden name=\"address\" value=\"";
print $input->param('address'), "\">\n";
print "<input type=hidden name=\"phone\" value=\"";
print $input->param('phone'), "\">\n";
print "<input type=hidden name=\"email\" value=\"";
print $input->param('email'), "\">\n";

print "<table border=0>\n";
print "<tr><td align=right>Credit Card Number:</td>\n";
print "<td><input type=text size=20 maxsize=20
name=\"ccnumber\"></td></tr>\n";
print "<tr><td align=right> Credit Card Expiration Date:</td>\n";
print "<td><input type=text size=4 maxsize=4
name=\"ccexpire\"></td></tr>\n";
print "<tr><td align=right>Shipping Options:</td>\n";
print "<td><select size=1 name=\"shipping\">\n";
print "<option value=\"overnight\">Overnight\n";
print "<option value=\"secondday\">Second Day\n";
print "<option value=\"parcel\">Parcel Post\n";
print "</select></td>\n</tr>\n";
print "<tr><td><br></td><input type=submit
value=\"PlaceOrder\"></td></tr>\n";
print "</table>\n</div>\n";
print "</form>\n";
print "</body>\n</html>\n";


Wow!!! That looks like alot. Well, any pointers would be appreciated.

Thanks,
Wayne D.

 
Reply With Quote
 
 
 
 
Wayne Deleersnyder
Guest
Posts: n/a
 
      11-21-2003
Hmmm.... kick me in the rear someone. Took me a couple of moments to
realize I hadn't properly set the permissions. D'oh!!!

Later,
Wayne D.


Wayne Deleersnyder wrote:
> Hi,
>
> I'm a newbie at Perl and CGI and hoping someone can point me in the
> right direction.
>
> Recently I've been going through an older book I have on CGI programming
> to get a start. Most of it involves using Perl 5 though. The book is
> "Sams Teach Yourself CGI Programming In A Week", by Rafe Colburn. Until
> recently, things were going smoothly. Then, depending on the script
> that I'd copy from the book, I'd start getting "Premature end of script
> headers" errors in my error_log.
>
> The script that I'm trying to get working right now is used for session
> tracking. Simply passing information from an HTML page to the script,
> which embeds the information in hidden fields.
>
> But everytime I run the script I get a 500 Internal Server Error and the
> error_log says: "Premature end of script headers: doform.cgi, referer:
> http://testsite/form1.html"
>
> I'm not sure if this is because of some configuration on my server or
> because I'm using the CGI.pm module. This error only pops up when I
> have "use CGI;" in the script.
>
> Here's the script and HTML form if it'll help:
>
> This is the form1.html page:
> <html>
> <head>
> <title>Order Form</title>
> </head>
>
> <body>
> <h1 alighn=center>Order Form, Part 1</h1>
>
> <div align=center>
> <form action="/cgi-bin/doform.cgi" method="post">
> <table border=0>
> <tr>
> <td align=right>Name:</td>
> <td><input type=text size=40 maxsize=80 name="address"></td>
> </tr>
> <tr>
> <td align=right>Phone Number:</td>
> <td><input type=text size=20 maxsize=20 name="phone"></td>
> </tr>
> <tr>
> <td align=right>Email Address:</td>
> <td><input type=text size=40 maxsize=40 name="email"></td>
> </tr>
> <tr>
> <td><br></td>
> <td><input type=submit value="Place Order"></td>
> </tr>
> </table>
> </form>
> </div>
> </body>
> </html>
>
>
>
> This is the doform.cgi script.
> #!/usr/bin/perl
> use CGI;
> $input = new CGI;
>
> # The param() method contains all of the data gathered
> # from the form, stored undre the name of each field.
> # All this CGI script hass to do is store that data in the
> # new form that it creates.
>
> print $input->header;
>
> print "<html>\n<head>\n<title>Order Form, Part 2</title>\n</head>\n";
> print "<body>\n";
> print "<h1 align=cneter>Order Form, Part 2</h1>\n";
> print "<form action=\"cgi-bin\"doform2.cgi\" method=\"post\"\n";
> print "<div align=center>";
>
> print "<input type=hidden name=\"name\" value=\"";
> print $input->param('name'), "\">\n";
> print "<input type=hidden name=\"address\" value=\"";
> print $input->param('address'), "\">\n";
> print "<input type=hidden name=\"phone\" value=\"";
> print $input->param('phone'), "\">\n";
> print "<input type=hidden name=\"email\" value=\"";
> print $input->param('email'), "\">\n";
>
> print "<table border=0>\n";
> print "<tr><td align=right>Credit Card Number:</td>\n";
> print "<td><input type=text size=20 maxsize=20
> name=\"ccnumber\"></td></tr>\n";
> print "<tr><td align=right> Credit Card Expiration Date:</td>\n";
> print "<td><input type=text size=4 maxsize=4
> name=\"ccexpire\"></td></tr>\n";
> print "<tr><td align=right>Shipping Options:</td>\n";
> print "<td><select size=1 name=\"shipping\">\n";
> print "<option value=\"overnight\">Overnight\n";
> print "<option value=\"secondday\">Second Day\n";
> print "<option value=\"parcel\">Parcel Post\n";
> print "</select></td>\n</tr>\n";
> print "<tr><td><br></td><input type=submit
> value=\"PlaceOrder\"></td></tr>\n";
> print "</table>\n</div>\n";
> print "</form>\n";
> print "</body>\n</html>\n";
>
>
> Wow!!! That looks like alot. Well, any pointers would be appreciated.
>
> Thanks,
> Wayne D.
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Webrick problem, PREMATURE END OF SCRIPT HEADERS Kevin Layman Ruby 3 05-22-2009 12:08 AM
Windows cgihandler Error: Premature end of script headers Kevin Layman Ruby 3 05-21-2009 11:59 PM
Re: premature end of script headers Phil Frost Python 0 07-10-2004 03:24 AM
'Premature end of script headers' error when starting Apache inboot time Greeshma Python 1 02-27-2004 08:19 AM
'Premature end of script headers' error when starting Apache inboot time Greeshma Python 0 02-25-2004 04:44 AM



Advertisments