#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    I keep getting the following error when running this script that basically emails form data to the user.

    [Thu Nov 30 01:43:29 2000] [error] [client xxx.IP.add.res] Premature end of
    script headers: /opt/apache/cgi-bin/dash1process.cgi

    I have been able to use a simple version with just one text box successfully send an email with no problem so I know apache is configured ok. I can't for the life of me figure this one out. As per many bulletin boards I have checked permissions and syntax in the script with no success. If anyone can help I would greatly appreciate it. Here is the code.

    ###########################
    #!/usr/local/bin/perl
    ##############################################################################
    # DD-175-1 Perl Script to email -1 request to the watch #
    ##############################################################################
    # Define Variables
    #
    $background = 'bgcolor="#8080FF"';
    $textcolor = '"#000080"';
    $mailprog = '/usr/lib/sendmail -t';
    $mailname = 'DD-175-1 Submission';
    $email = 'mymail@domainname.mil';
    $homeurl = 'http://www.ourwebsite.mil';
    ##############################################################################
    # Form Variables
    $flightdate = $INPUT{'flightdate'};
    $departtime = $INPUT{'departtime'};
    $actype = $INPUT{'actype'};
    $callsign = $INPUT{'callsign'};

    $dest1 = $INPUT{'dest1'};
    $eta1 = $INPUT{'eta1'};
    $flightlevel1 = $INPUT{'flightlevel1'};
    $alt1 = $INPUT{'alt1'};
    $tlog1 = $INPUT{'tlog1'};

    $dest2 = $INPUT{'dest2'};
    $eta2 = $INPUT{'eta2'};
    $flightlevel2 = $INPUT{'flightlevel2'};
    $alt2 = $INPUT{'alt2'};
    $tlog2 = $INPUT{'tlog2'};

    $dest3 = $INPUT{'dest3'};
    $eta3 = $INPUT{'eta3'};
    $flightlevel3 = $INPUT{'flightlevel3'};
    $alt3 = $INPUT{'alt3'};
    $tlog3 = $INPUT{'tlog3'};

    $dest4 = $INPUT{'dest4'};
    $eta4 = $INPUT{'eta4'};
    $flightlevel4 = $INPUT{'flightlevel4'};
    $alt4 = $INPUT{'alt4'};
    $tlog4 = $INPUT{'tlog4'};

    $dest5 = $INPUT{'dest5'};
    $eta5 = $INPUT{'eta5'};
    $flightlevel5 = $INPUT{'flightlevel5'};
    $alt5 = $INPUT{'alt5'};
    $tlog5 = $INPUT{'tlog5'};

    $dest6 = $INPUT{'dest6'};
    $eta6 = $INPUT{'eta6'};
    $flightlevel6 = $INPUT{'flightlevel6'};
    $alt6 = $INPUT{'alt6'};
    $tlog6 = $INPUT{'tlog6'};

    $oparscheck = $INPUT{'oparscheck'};
    $hwdcheck = $INPUT{'hwdcheck'};
    $vipcheck = $INPUT{'vipcheck'};
    $vipname = $INPUT{'vipname'};
    $viptitle = $INPUT{'viptitle'};
    $todaydate = $INPUT{'todaydate'};
    $currenttime = $INPUT{'currenttime'};
    $req_dev_time = $INPUT{'req_dev_time'};
    $pilotname = $INPUT{'pilotname'};
    $delivermethod = $INPUT{'delivermethod'};

    $faxnumber = $INPUT{'faxnumber'};
    $recipient = $INPUT{'recipient'};
    $pilotnumber = $INPUT{'pilotnumber'};
    $comments = $INPUT{'comments'};
    $sendkey = $INPUT{'send'};

    ############################################################################
    BELOW HERE

    &read;

    if ($INPUT{'send'}) { &checkform; &mail; &thanks; }
    exit;

    #
    ############################################################################
    sub read {

    if ($ENV{'REQUEST_METHOD'} eq 'POST') {
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);
    }
    elsif ($ENV{'REQUEST_METHOD'} eq 'GET') {
    @pairs = split(/&/, $ENV{'QUERY_STRING'});
    }
    else {
    &error('request_method');
    }
    }

    # if ($ENV{'QUERY_STRING'}) {$namevalues = $ENV{'QUERY_STRING'};}
    # else {read(STDIN, $namevalues, $ENV{'CONTENT_LENGTH'});}
    # @pairs = split(/&/, $namevalues);

    foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $name =~ tr/+/ /;
    $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/<!--(.|n)*-->//g;
    $value =~ s/<([^>]|n)*>//g;
    $INPUT{$name} = $value;

    }
    ############################################################################
    sub checkform {

    $num = 0;

    if ($flightdate eq '') { $num = ($num + 1); }
    if ($departtime eq '') { $num = ($num + 1); }
    if ($actype eq '') { $num = ($num + 1); }
    if ($callsign eq '') { $num = ($num + 1); }
    if ($dest1 eq '') { $num = ($num + 1); }
    if ($eta1 eq '') { $num = ($num + 1); }
    if ($flightlevel1 eq '') { $num = ($num + 1); }
    if ($tlog1 eq '') { $num = ($num + 1); }
    if ($todaydate eq '') { $num = ($num + 1); }
    if ($currenttime eq '') { $num = ($num + 1); }
    if ($req_dev_time eq '') { $num = ($num + 1); }
    if ($pilotname eq '') { $num = ($num + 1); }
    if ($delivermethod eq '') { $num = ($num + 1); }
    if ($faxnumber eq '') { $num = ($num + 1); }
    if ($recipient eq '') { $num = ($num + 1); }
    if ($pilotnumber eq '') { $num = ($num + 1); }
    if ($comments eq '') { $num = ($num + 1); }
    if ($num ne 0) {

    print "Content-type: text/htmlnn";
    print "<HTML>n";
    print "<HEAD>n";
    print "<TITLE>Please complete all fields before sending.</TITLE></HEAD>n";
    print "</HEAD>n";
    print "<H2>DD-175-1 FORM ERROR MESSAGE</H2>n";
    print "<font face=verdana size=2 color='#0000FF'><b>n";
    print "Please complete all supplied form fields<br></b></font>n";
    print "<font face=verdana size=2 color='#FF0000><b>n";
    print "$num Form fields not completed<p><FORM>n";
    print "<INPUT TYPE=button VALUE='RETRY' onClick='history.go(-1)'></FORM>n";
    print "</HEAD>n";
    print "<HTML>n";

    exit;}

    }
    ############################################################################
    sub mail {
    open (MAIL, "|$mailprog");
    print MAIL "To: $emailn";
    print MAIL "From: $recipientn";
    print MAIL "Subject: $mailname Departing: $flightdate $departtimen";
    print MAIL "********************** POC INFORMATION *********************n";
    print MAIL "Pilot: $pilotnamen";
    print MAIL "Phone: $pilotnumber Email: $recipient Fax: $faxnumbern";
    print MAIL "Date and Time Submitted: $currenttime $todaydaten";
    print MAIL "Requested Delivery Time: $req_dev_timen";
    print MAIL "Requested Delivery Method: $delivermethodn";
    print MAIL "********* ADDITIONAL PACKAGES AND SUPPORT INFORMATION
    *********n";
    # Check for HWD
    if ($hwdcheck eq 'Yes') {print MAIL "HWD: HWD REQUESTEDn";}
    else {print MAIL "HWD: None Requestedn";}
    # Check for OPARS
    if ($oparscheck eq 'Yes') {print MAIL "Opars: OPARS REQUESTEDn";}
    else {print MAIL "Opars: No OPARS Requestedn";}
    # Check for VIP package
    if ($vipcheck eq 'Yes') {
    print MAIL "VIP NAME: $vipnamen";
    print MAIL "VIP TITLE: $viptitlen";
    }
    else {print MAIL "VIP: None Requestedn";}

    print MAIL "********************** FLIGHT INFORMATION
    *********************n";
    print MAIL "FLight Date: $flightdate Flight Time: $departtimen";
    print MAIL "Aircraft Type: $actype Call Sign: $callsignn";

    # Leg 1 information
    print MAIL "Leg 1 Destination: $dest1n";
    print MAIL "Leg 1 ETA: $eta1n";
    print MAIL "Leg 1 Flight Level: $flightlevel1n";
    print MAIL "Leg 1 Alternate: $alt1n";
    print MAIL "Leg 1 Time On Ground: $tlog1n";

    # Leg 2 information
    print MAIL "Leg 2 Destination: $dest2n";
    print MAIL "Leg 2 ETA: $eta2n";
    print MAIL "Leg 2 Flight Level: $flightlevel2n";
    print MAIL "Leg 2 Alternate: $alt2n";
    print MAIL "Leg 2 Time On Ground: $tlog2n";

    # Leg 3 information
    print MAIL "Leg 3 Destination: $dest3n";
    print MAIL "Leg 3 ETA: $eta3n";
    print MAIL "Leg 3 Flight Level: $flightlevel3n";
    print MAIL "Leg 3 Alternate: $alt3n";
    print MAIL "Leg 3 Time On Ground: $tlog3n";

    # Leg 4 information
    print MAIL "Leg 4 Destination: $dest4n";
    print MAIL "Leg 4 ETA: $eta4n";
    print MAIL "Leg 4 Flight Level: $flightlevel4n";
    print MAIL "Leg 4 Alternate: $alt4n";
    print MAIL "Leg 4 Time On Ground: $tlog4n";

    # Leg 5 information
    print MAIL "Leg 5 Destination: $dest5n";
    print MAIL "Leg 5 ETA: $eta5n";
    print MAIL "Leg 5 Flight Level: $flightlevel5n";
    print MAIL "Leg 5 Alternate: $alt5n";
    print MAIL "Leg 5 Time On Ground: $tlog5n";

    # Leg 6 information
    print MAIL "Leg 6 Destination: $dest6n";
    print MAIL "Leg 6 ETA: $eta6n";
    print MAIL "Leg 6 Flight Level: $flightlevel6n";
    print MAIL "Leg 6 Alternate: $alt6n";
    print MAIL "Leg 6 Time On Ground: $tlog6n";
    print MAIL "********************** ADDITIONAL COMMENTS
    *********************n";
    print MAIL "$commentsn";
    close(MAIL);

    }
    ############################################################################
    sub error {

    if ($error eq 'request_method') {
    print <<"(END ERROR HTML)";
    Content-type: text/html

    <html>
    <head>
    <title>Error: Request Method</title>
    </head>

    <body>
    <center>
    Request method of the form you submitted did not match GET or POST
    </center>
    </body>
    </html>
    (END ERROR HTML)
    }
    ############################################################################
    sub thanks {

    print "Content-type: text/htmlnn";
    print "<HTML>n";
    print "<HEAD>n";
    print "<TITLE>Thank you for submitting your request online
    $pilotname</TITLE></HEAD>n";
    print "<BODY $background vlink='#00FF00' text=$textcolor><CENTER><BR>n";
    print "<TABLE border=0 cellspacing=0 cellpadding=35 width=90%><TR>n";
    print "<TD align=center><font face=verdana size='+3'>Mail Sent</font>n";
    print "<P><font face='verdana' size=2><b>n";
    print "$pilotname your submittal has been sent to the weather
    office.<BR><BR><BR>n";
    print "<a href='$homeurl'>HOME</a></b></font></TR></TD></TABLE><BR>n";
    print "<hr width=90%>n";
    print "</BODY>n";
    print "</HTML>n";

    exit;

    }
    }

    #####################
    HERE is the HTML Page which is seperate.
    ####################
    <html>

    <head>
    <title>DD175-1 REQUEST FORM</title>
    </head>

    <body bgcolor="#c0c0c0" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

    <table width="100%">
    <tr>
    <td width="90%"><b><h1 align="center">DD175-1 WEATHER REQUEST FORM</b> <br>
    <font color="#FF0000"><small><small><small>* Required Fields</small></small></small><br>
    </font><font color="#FFFFFF"><small><small><small>(EXAMPLES)</small></small></small></font></h1>
    </td>
    </tr>
    </table>

    <form method="POST" action="../cgi-bin/dash1process.cgi">
    <table width="100%" border="0" cellspacing="0" cellpadding="4">
    <tr>
    <!-- Row 1 Column 1 -->
    <td align="center"><font color="#FF0000"><b>*</b></font>FLIGHT DATE:<br>
    <font color="#FFFFFF">(03JUN00)</font><br><b>
    <input type="text" name="flightdate" size="20" maxlength="80" value></b></td>
    <!-- Row 1 Column 2 -->
    <td align="center"><font color="#FF0000"><b>*</b></font>DEPARTURE TIME(Z):<br>
    <font color="#FFFFFF">(1300)</font><br><b>
    <input type="text" name="departtime" size="20" maxlength="80" value></b></td>
    <!-- Row 1 Column 3 -->
    <td align="center"><font color="#FF0000"><b>*</b></font>A/C TYPE:<br>
    <font color="#FFFFFF">(C-2)</font><br><b>
    <input type="text" name="actype" size="20" maxlength="80" value></b></td>
    <!-- Row 1 Column 4 -->
    <td align="center"><font color="#FF0000"><b>*</b></font>A/C CALLSIGN:<br>
    <font color="#FFFFFF">(EAGLE 20)<br><b>
    <input type="text" name="callsign" size="20" maxlength="80" value></b></td>
    </tr>
    </table>

    <table width="100%">
    <tr>
    <td width="5%" align="center"># </td>
    <td width="19%" align="center">DESTINATION: <br>
    <font color="#FFFFFF">(KNZY)<br>
    </font><font color="#FF0000">*Line 1 Only</font></td>
    <td width="19%" align="center">ETA: <br>
    <font color="#FFFFFF">(1500)<br>
    </font><font color="#FF0000">*Line 1 Only</font></td>
    <td width="19%" align="center">FLIGHT LEVEL: <br>
    <font color="#FFFFFF">(020 for 2000FT)<br>
    </font><font color="#FF0000">*Line 1 Only</font></td>
    <td width="19%" align="center" valign="top">ALTERNATE: <br>
    <font color="#FFFFFF">(KNZY)</font></td>
    <td width="19%" align="center">TIME ON GROUND<br>
    <font color="#FFFFFF">(45 for 45 Min.)<br>
    </font><font color="#FF0000">(Required for OPARS)</font>: </td>
    </tr>
    <tr>
    <td width="5%" align="center">1 </td>
    <td width="19%" align="center">
    <input type="text" name="dest1" size="20" maxlength="80"> </td>
    <td width="19%" align="center">
    <input type="text" name="eta1" size="20" maxlength="80"> </td>
    <td width="19%" align="center">
    <input type="text" name="flightlevel1" size="20" maxlength="80"> </td>
    <td width="19%" align="center"><input type="text" name="alt1" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="tog1" size="20" maxlength="80"></td>
    </tr>
    <tr>
    <td width="5%" align="center">2 </td>
    <td width="19%" align="center"><input type="text" name="dest2" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="eta2" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="flightlevel2" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="alt2" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="tog2" size="20" maxlength="80"></td>
    </tr>
    <tr>
    <td width="5%" align="center">3 </td>
    <td width="19%" align="center"><input type="text" name="dest3" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="eta3" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="flightlevel3" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="alt3" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="tog3" size="20" maxlength="80"></td>
    </tr>
    <tr>
    <td width="5%" align="center">4 </td>
    <td width="19%" align="center"><input type="text" name="dest4" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="eta4" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="flightlevel4" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="alt4" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="tog4" size="20" maxlength="80"></td>
    </tr>
    <tr>
    <td width="5%" align="center">5 </td>
    <td width="19%" align="center"><input type="text" name="dest5" size="20" maxlength="80"><br></td>
    <td width="19%" align="center"><input type="text" name="eta5" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="flightlevel5" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="alt5" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="tog5" size="20" maxlength="80"></td>
    </tr>
    <tr>
    <td width="5%" align="center">6 </td>
    <td width="19%" align="center"><input type="text" name="dest6" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="eta6" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="flightlevel6" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="alt6" size="20" maxlength="80"></td>
    <td width="19%" align="center"><input type="text" name="tog6" size="20" maxlength="80"></td>
    </tr>
    </table>
    <table width="100%">
    <tr>
    <td width="33%" align="center" valign="top"><input type="checkbox" name="oparscheck" value="Yes">OPARS <br>
    <font color="#FFFFFF">Check if required. Please specify, in the comments block below,
    if you would like your Cargo Calculated, what your drag count is, fuel
    reserves you would like and the type of routing you prefer.</font></td>
    <td width="33%" align="center" valign="top"><input type="checkbox" name="hwdcheck" value="Yes">HWD <br>
    <font color="#FFFFFF">Check if Required</font></td>
    <td width="33%" align="center"><input type="checkbox" name="vipcheck" value="Yes">VIP PACKAGE<br>
    <font color="#FFFFFF">Check if Required. </font><font color="#FF0000">If Checked, Name and
    Title are Required.</font><font color="#FFFFFF"><br>
    </font>
    <font color="#FF0000">VIP NAME</font> <input type="text" name="vipname" size="20" maxlength="80"><br>
    <font color="#FF0000">VIP TITLE</font> <input type="text" name="viptitle" size="20" maxlength="80"> </td>
    </tr>
    </table>
    <p>PICK-UP INFORMATION:</p>
    <table WIDTH="100%">
    <tr>
    <td WIDTH="25%" ALIGN="CENTER"><font color="#FF0000"><b>*</b></font>TODAY'S DATE<br>
    <font color="#FFFFFF">(03JUN00)<br>
    </font>
    <input type="text" name="todaydate" size="20" maxlength="80"></td>
    <td WIDTH="25%" ALIGN="CENTER"><font color="#FF0000"><b>*</b></font>CURRENT TIME(L):<br>
    <font color="#FFFFFF">(0500)<br>
    </font>
    <input type="text" name="currenttime" size="20" maxlength="80"></td>
    <td WIDTH="25%" ALIGN="CENTER"><font color="#FF0000"><b>*</b></font>REQUESTED DELIVERY
    TIME<br>
    (L):<br>
    <font color="#FFFFFF">(0545, Allow 30 Min from Current Time)<br>
    </font>
    <input type="text" name="req_dev_time" size="20" maxlength="80"></td>
    <td WIDTH="25%" ALIGN="CENTER"><font color="#FF0000"><b>*</b></font>PILOT NAME<br>
    <font color="#FFFFFF">(Rank and Last Name)<br>
    </font>
    <input type="text" name="pilotname" size="20" maxlength="80"></td>
    </tr>
    <tr>
    <td WIDTH="25%" ALIGN="CENTER"><font color="#FF0000"><b>*</b></font>DELIVERY METHOD:<br>
    <select name="delivermethod" size="1">
    <option selected value="Fax">Fax</option>
    <option value="Pick-up">Pick-up</option>
    <option value="E-mail">E-mail</option>
    </select> </td>
    <td WIDTH="25%" ALIGN="CENTER">FAX NUMBER:<br>
    <font color="#FFFFFF">(Last 5 Digits)<br>
    </font><input type="text" name="faxnumber" size="20" maxlength="80"> </td>
    <td WIDTH="25%" ALIGN="CENTER">E-MAIL ADDRESS:<br>
    <font color="#FFFFFF">(Command E-mail)<br>
    </font><input type="text" name="recipient" size="20" maxlength="80"> </td>
    <td WIDTH="25%" ALIGN="CENTER"><font color="#FF0000"><b>*</b></font>PILOT PHONE NUMBER<br>
    <font color="#FFFFFF">(Last 5 Digits)<br>
    </font>
    <input type="text" name="pilotnumber" size="20" maxlength="80"> </td>
    </tr>
    <tr>
    <td WIDTH="25%" colspan="4">COMMENTS:<br>
    <textarea name="comments" rows="3" cols="100"></textarea> </td>
    </tr>
    </table>
    <p><input type="submit" value="SUBMIT"> <input
    type="reset" value="RESET"> </p>

    </form>
    </body>
    </html>


  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    You should put &read sub before these lines:

    &read;
    # Form Variables
    $flightdate = $INPUT{'flightdate'};
    $departtime = $INPUT{'departtime'};
    $actype = $INPUT{'actype'};
    ....
    Otherwise your variables are empty!

    In sub read {} you don't need 2nd "$value =~ tr/+/ /;" lines.
    Let me know is it working now.

    [This message has been edited by Pepe (edited December 01, 2000).]

IMN logo majestic logo threadwatch logo seochat tools logo