Premature end of script headers

From: Wayne Deleersnyder (wdeleersnyder_at_netscape.net)
Date: 11/21/03

  • Next message: Wayne Deleersnyder: "Re: Premature end of script headers"
    Date: Fri, 21 Nov 2003 07:52:22 -0500
    
    

    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.


  • Next message: Wayne Deleersnyder: "Re: Premature end of script headers"

    Relevant Pages

    • Re: Help with a stragegy for diagnosis
      ... I have a Perl CGI that has work for years. ... first failure and before the second. ... A strategy would be to write tests for the script until you get the same ...
      (comp.lang.perl.moderated)
    • FAQ 9.1 What is the correct form of response from a CGI script?
      ... This message is one of several periodic postings to comp.lang.perl.misc ... from the documentation provided with Perl. ... What is the correct form of response from a CGI script? ... The Common Gateway Interface (CGI) specifies a software interface ...
      (comp.lang.perl.misc)
    • FAQ 9.1 What is the correct form of response from a CGI script?
      ... This message is one of several periodic postings to comp.lang.perl.misc ... from the documentation provided with Perl. ... What is the correct form of response from a CGI script? ... The Common Gateway Interface (CGI) specifies a software interface ...
      (comp.lang.perl.misc)
    • Re: How to write to drive A: from CGI Perl
      ... >> If that does not look weird to you, then please go back to basics. ... Please (assuming that the quoted text is an actual excerpt from the HTML ... You will have a better version of Perl? ... for HTML or Perl or CGI or anything. ...
      (comp.lang.perl.misc)
    • Re: Advice about cgi programming
      ... experience with other scripting languages. ... This might not be the most appropriate group, but since Perl is ... input string to this script in the background and return the result. ... Perl is an excellent choice for writing CGI programs. ...
      (comp.lang.perl.misc)