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.