Page not printing results [closed]

-1

I am creating a table with a cell in the form of input text to enter a number, and the rest of the cells will be printed after the operations have been performed to determine its value.

After the table has a submit button to send the value of the input text to the variable that will initiate the calculations.

It turns out that I can not print the results.

<form method="POST" action="meixautonomo.php">
<table border="1">
    <tr>
        <td class="indicador">Informações Gerais</td>
        <td class="indicador">Autonômo</td>
        <td class="indicador">MEI/ME</td>
        <td class="indicador">% de Econômia</td>
    </tr>
    <tr>
        <td>Bônus Bruto</td>
        <td><input type="text" name="entrada"></td>
        <?php
            if(isset($_POST['calcular'])){
                $autonomoBonusBruto = $_POST['entrada'];
                $meimeBonusBruto = $autonomoBonusBruto;
                $porcEconomiaBonusBruto = ($autonomoBonusBruto - $meimeBonusBruto) / $autonomoBonusBruto;
                $autonomoTaxa = 3;
                $meimeTaxa = 3.99;
                $porcEconomiaTaxa = ($autonomoTaxa - $meimeTaxa) / $autonomoTaxa;
                $autonomoINSS;
                if($autonomoTaxa + $meimeTaxa > 5189.82){
                    $autonomoINSS = 570.88;
                }
                else{
                    $autonomoINSS = ($autonomoBonusBruto - $autonomoTaxa) * 0.11;
                }
                $meimeINSS;
                if($meimeBonusBruto <= 5000){
                    $meimeINSS = 44;
                }
                else if($meimeBonusBruto > 5189.82){
                    $meimeINSS = 570.88; 
                }
                else{
                    $meimeINSS = $meimeBonusBruto * 0.11;
                }
                $porcEconomiaINSS = ($autonomoINSS - $meimeINSS) / $autonomoINSS;
                $autonomoIRRF = 2864.91 * 0.15 - 354.80;
                $meimeIRRF;
                if($meimeBonusBruto <= 5000){
                    $meimeIRRF = 21033.22 * 0 - 0 / 12;
                }
                else{
                    $meimeIRRF = $meimeBonusBruto * 0.06;
                }
                $porcEconomiaIRRF = ($autonomoIRRF - $meimeIRRF) / $autonomoIRRF;
                $autonomoISS = $autonomoBonusBruto * 0.05;
                $meimeISS;
                if($meimeBonusBruto <= 5000){
                    $meimeISS = 5; 
                }
                else{
                    $meimeISS = $meimeBonusBruto * 0.05;
                }
                $porcEconomiaISS = ($autonomoISS - $meimeISS) / $autonomoISS;
                $autonomoBonusLiquido = $autonomoBonusBruto - $autonomoTaxa - $autonomoINSS - $autonomoIRRF - $autonomoISS;
                $meimeBonusLiquido = $meimeBonusBruto - $meimeTaxa - $meimeINSS - $meimeIRRF - $meimeISS;
                $porcEconomiaBonusLiquido = ($autonomoBonusLiquido - $meimeBonusLiquido) / $autonomoBonusLiquido;
                $meimeLucro = $meimeBonusLiquido - $autonomoBonusLiquido;
        ?>          
        <td><?php echo $meimeBonusBruto;?></td>
        <td><?php echo $porcEconomiaBonusBruto;?></td>
    </tr>
    <tr>
        <td>Taxa DOC/Boleto</td>
        <td><?php echo $autonomoTaxa;?></td>
        <td><?php echo $meimeTaxa;?></td>
        <td><?php echo $porcEconomiaTaxa;?></td>
    </tr>
    <tr>
        <td>INSS</td>
        <td><?php echo $autonomoINSS;?></td>
        <td><?php echo $meimeINSS;?></td>
        <td><?php echo $porcEconomiaINSS;?></td>
    </tr>
    <tr>
        <td>IRRF</td>
        <td><?php echo $autonomoIRRF;?></td>
        <td><?php echo $meimeIRRF;?></td>
        <td><?php echo $porcEconomiaIRRF;?></td>
    </tr>
    <tr>
        <td>ISS</td>
        <td><?php echo $autonomoISS;?></td>
        <td><?php echo $meimeISS;?></td>
        <td><?php echo $porcEconomiaISS;?></td>
    </tr>
    <tr>
        <td>Bônus Líquido</td>
        <td><?php echo $autonomoBonusLiquido;?></td>
        <td><?php echo $meimeBonusLiquido;?></td>
        <td><?php echo $porcEconomiaBonusLiquido;?></td>
    </tr>
</table>
<?php echo $meimeLucro;}?>
<br>
<input type="submit" name="calcular" value="Gerar resultados">
</form>
    
asked by anonymous 14.12.2016 / 04:27

3 answers

2

Read the comments next to the variables.

If there is no action, the form is submitted to the same page.

<form method = "POST">
<table border = "1">
    <tr>
        <td class = "indicador">Informações Gerais</td>
        <td class = "indicador">Autonômo</td>
        <td class = "indicador">MEI/ME</td>
        <td class = "indicador">% de Econômia</td>
    </tr>
    <tr>
        <td>Bônus Bruto</td>
        <td><input type = "text" name = "entrada" id="entrada" /></td>
        <?php 
        if(isset($_POST['calcular']))
        {
            $autonomoBonusBruto = $_POST['entrada'];
            $autonomoTaxa = 3;
            $autonomoINSS    =1;      // VARIÁVEL = NULL SE NÃO TIVER VALOR DEFINIDO, divisão por zero não existe
            $autonomoIRRF;           // variável não sendo utilizada
            $autonomoISS;               // variável não sendo utilizada
            $autonomoBonusLiquido;  // variável não sendo utilizada
            $meimeBonusBruto = $autonomoBonusBruto;
            $meimeTaxa = 3.99;
            $meimeINSS    =0;            // VARIÁVEL = NULL SE NÃO TIVER VALOR DEFINIDO
            $meimeIRRF;                // variável não sendo utilizada
            $meimeISS;                // variável não sendo utilizada
            $meimeBonusLiquido;        // variável não sendo utilizada

            $porcEconomiaBonusBruto = ($autonomoBonusBruto - $meimeBonusBruto) / $autonomoBonusBruto;
            $porcEconomiaTaxa = ($autonomoTaxa - $meimeTaxa) / $autonomoTaxa;
            $porcEconomiaINSS = ($autonomoINSS - $meimeINSS) / $autonomoINSS;
            $porcEconomiaIRRF;     // variável não sendo utilizada
            $porcEconomiaISS;     // variável não sendo utilizada
            $porcEconomiaBonusLiquido;     // variável não sendo utilizada

            echo '<td>'.$meimeBonusBruto.'</td>';
            echo '<td>'.$porcEconomiaBonusBruto.'</td>';
        }
        else
        {
            echo '<td></td>
                  <td></td>';
        }
        ?>          

    </tr>
</table>
<br/>
<input type = "submit" name = "calcular" value = "Gerar resultados"/>
</form>


<script>
window.onload=function(){ document.getElementById('entrada').focus(); }
</script>
    
14.12.2016 / 13:25
2

It's not very clear what you're asking, but at first glancing superficially you notice basic mistakes.

Below, I will quote the most visible. But it does not necessarily mean that they are the cause of the problem, however, I suspect that at least 1 or 2 of those errors are causing the problem. So I recommend that you fix them

PHP: Simple quotation marks to print variables

Example:

<?php echo '$porcEconomiaBonusBruto';?>
<?php echo '$meimeBonusBruto';?>

This will literally print due to single quotes. It will be written literally:

$porcEconomiaBonusBruto
$meimeBonusBruto

A variable does not need to be quoted by quotation marks.

Please correct this:

<?php echo $porcEconomiaBonusBruto;?>
<?php echo $meimeBonusBruto;?>

HTML: Spaces in attribute assignors and XML markup

Example:

<input type = "submit" name = "calcular" value = "Gerar resultados"/>

You do not need to have spaces in the assigners. Correction:

<input type="submit" name="calcular" value="Gerar resultados">

The bar at the end also removed. This you use if the DTD is XHTML.

HTML: Syntax error (tag table)

One problem that can be serious is the lack of the closing character of the tag <table

<table border = "1"
    <tr>

> is missing to close. Correction:

<table border="1">
    <tr>

Maybe that's where you're keeping from seeing the results. But if you press CTRL + U (chrome), you can see the codes.

HTML: The form is without action

<form method = "POST">

Example of how it should be:

<form method="POST" action="pagina.php">

Here in this place where "pagina.php" is, obviously is an EXAMPLE. You should put the page that will receive the data.

Other

Just note, the PHP stretch with this mountain of null variables, does not make any sense.

It also does not make much sense for the expression $porcEconomiaBonusBruto to receive because it always results in ZERO.

Basically, you are assigning $_POST['entrada'] to a $autonomoBonusBruto variable that is used to assign value to another variable $meimeBonusBruto . Finally,

$porcEconomiaBonusBruto = ($autonomoBonusBruto - $meimeBonusBruto) / $autonomoBonusBruto;

It's the same as ($_POST['entrada'] - $_POST['entrada']) / $_POST['entrada'] .

I do not know what you want with this, so I refrain from prolonging this subject, but I thought it pertinent to comment.

    
14.12.2016 / 05:01
0
  • Assign values for the variables $autonomoINSS and $meimeINSS because the calculation can not be done with null values.
  • Remove the quotation marks when printing variable values.
14.12.2016 / 13:55