Premature end of script headers

Discussion in 'Perl' started by Wayne Deleersnyder, Nov 21, 2003.

  1. 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.
     
    Wayne Deleersnyder, Nov 21, 2003
    #1
    1. Advertising

  2. 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.
    >
     
    Wayne Deleersnyder, Nov 21, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greeshma
    Replies:
    0
    Views:
    363
    Greeshma
    Feb 25, 2004
  2. Greeshma
    Replies:
    1
    Views:
    509
  3. Phil Frost

    Re: premature end of script headers

    Phil Frost, Jul 10, 2004, in forum: Python
    Replies:
    0
    Views:
    558
    Phil Frost
    Jul 10, 2004
  4. Kevin Layman
    Replies:
    3
    Views:
    145
    Diego Guillen
    May 22, 2009
  5. Kevin Layman
    Replies:
    3
    Views:
    190
    Diego Guillen
    May 22, 2009
Loading...

Share This Page