End of script output before headers: converter.cgi

0

I have this same problem and I already verified the syntax of the Perl script and I see that everything is correct, I do not understand the reason why it does not work. Here is the layout of the form:

<form id="formu" action="convertidor.cgi" method="POST" class="form register">
    <h2 class="form_titulo"> Convertidor de temperaturas </h2>
    <div class="contenedor-inputs">
        <br>
        <input type="text" name="grados"  id="nombre" placeholder="Ingresa el número de grados  " maxlength="10" class="input-100" required  />
        <center>
            <input type="radio" name="conver" id="CF" value="CF" checked>
            <label for="CF">Celsius a farenheit</label>
            <input type="radio" name="conver" id="CK" value="CK">
            <label for="CK">Celsius a Kelvin</label>
            <input type="radio" name="conver" id="FC" value="FC">
            <label for="FC">Farenheit a celsius</label>
            <input type="radio" name="conver" id="FK" value="FK">
            <label for="FK">Farenheit a kelvin</label>
            <br>
            <input type="radio" name="conver" id="KF" value="KF" >
            <label for="KF">Kelvin a celsius</label>
            <input type="radio" name="conver" id="KC" value="KC">
            <label for="KC">kelvin a celsius</label>
        </center>
        <center>
            <input class="form-btn" type="submit" id="btnenviar" value="Ingresar" />
        </center>
    </div>

and here the Perl script using the CGI module:

#!"C:\xampp\perl\bin\perl.exe"

use strict;
use CGI;

my $cgi = new CGI;

my $n1 = $cgi->param('grados');
my $op = $cgi->param('conver');

if ($n1 !~ /[0-9]+$/) {
    print $cgi->header("text/html");
    print "Error ha ingresado datos incorrectos";
    return;
}

my $total;

if ($op eq "CF") {
    $total = (9*$n1)/5+32;
}
elsif ($op eq "CK") {
    $total = $n1+273.15;
}
elsif ($op eq "FC") {
    $total = 5*($n1-32)/9;
}
elsif ($op eq "FK") {
    $total = (5*($n1-32)/9)+273.15;
}
elsif ($op eq "KC") {
    $total = 9($n-273.15)/5+32
}
elsif ($op eq "KF") {
    $total = $n1-273.15
}

print $cgi->header("text/html");
print $total;
    
asked by Carlos Saz 28.09.2017 в 02:54
source

1 answer

0

The line with the formula 9 ($ n-273.15) / 5 + 32 is misspelled (an operator is missing after '9'.

Use the '-c' option, as we have said in another thread, so that Perl will notify you of these errors.

Also, do not forget to see the error.log file of the web server, because there all these errors will appear.

    
answered by 29.09.2017 в 01:58