Problem submitting form with SELECT tag, empty $ _POST array

0

By submitting the form above, the PHP script is failing, stating that the 'estab' index is undefined. The 'var_dump' function shows an empty vector.

    <form action="PHP_scripts/gerarApp.php" method="post" onsubmit="return waiting()">
        <select id="estab" name="estab" class="form-control">
            <option value="0">Selecione o estabelecimento</option>
            <?php
            foreach($pdo->query("SELECT numEstabelecimento, nomeEstabelecimento FROM Estabelecimento") as $estab)
                echo '<option value='.$estab['numEstabelecimento'].'>'.htmlentities($estab['nomeEstabelecimento']).'</option>';
            ?>
        </select>

        <input type="submit" id="generateApp" value="Gerar Aplicativo" class="btn btn-lg btn-primary">
    </form>



<?php
var_dump($_POST);
$numEstab = $_POST['estab'];
?>

The curious thing is that I have another page with a form that contains a 'select' field and it works. I do not understand why this is not working.

Can anyone tell me where the error is? Many thanks.

    
asked by anonymous 14.03.2016 / 14:55

1 answer

0
<form action="PHP_scripts/gerarApp.php" method="post" onsubmit="return waiting()">
    <select id="estab" name="estab" class="form-control">
        <option value="0">Selecione o estabelecimento</option>
        <?php
        foreach($pdo->query("SELECT numEstabelecimento, nomeEstabelecimento FROM Estabelecimento") as $estab)
            echo '<option value="'.$estab['numEstabelecimento'].'">'.htmlentities($estab['nomeEstabelecimento']).'</option>';
        ?>
    </select>

    <input type="submit" id="generateApp" value="Gerar Aplicativo" class="btn btn-lg btn-primary">
</form>
    
18.03.2016 / 06:50