Sum in php does not work

-3

Good morning, I have the following problem: I want to add the initial evaluation with the final evaluation and the result appears on the screen but it always appears zero, where am I failing?

<th><divclass="input-field col s12">
        <input id="AvInicial" type="text" class="validate"
               autocomplete="off" name="AvInicial">
        <label for="avinicial"></label>
    </div>
</th>
<th>
    <div class="input-field col s12">
        <input id="Meta" type="text" class="validate" autocomplete="off"
               name="Meta">
        <label for="meta"></label>
    </div>
</th>
<th>
    <div class="input-field col s12">
        <input id="AvIntercalar" type="text" class="validate"
               autocomplete="off" name="AvIntercalar">
        <label for="avintercalar"></label>
    </div>
</th>
<th>
    <div class="input-field col s12">
        <input id="AvFinal" type="text" class="validate" autocomplete="off"
               name="AvFinal">
        <label for="avfinal"></label>
    </div>
</th>
<th>
    <div class="input-field col s12">
        <?
            $a = $_GET['avinicial'];
            $b = $_GET['avfinal'];
              echo $a + $b;
        ?>
    </div>
</th>
    
asked by anonymous 18.04.2018 / 13:23

1 answer

1

This is a basic example with 2 fields based on your form, try to use as an example to do with others.

<form action="">
    <table>
         <th>
            <div class="input-field col s12">
                <input id="AvInicial" type="text" class="validate"
                    autocomplete="off" name="AvInicial">
                <label for="avinicial">campo 1</label>
            </div>
        </th>            
        <th>
            <div class="input-field col s12">

                <label for="avfinal"> campo 4</label>
                <input id="Avfinal" type="text" class="validate"
                    autocomplete="off" name="Avfinal">
            </div>
        </th>
        <th>
            <div class="input-field col s12">
                <?php
                $a = isset($_GET['AvInicial']) ? $_GET['AvInicial'] : 0;
                $b = isset($_GET['Avfinal']) ? $_GET['Avfinal'] : 0;
                echo $a + $b;
                ?>

            </div>
        </th>
        <th>
            <button type="submit">Enviar</button>
        </th>
    
18.04.2018 / 14:09