I have a form system where fields are generated by the base date through select. The same is done with foreach, how can I fetch the base date from the required fields and see if they were filled in? And if they are not do not validate the form and display a message. OBS: I do not want to use required no input.
<?php
if (isset($_POST['acao'])) {
while (list ($key, $val) = each ($_POST)){
mysql_query("insert into cms_formularios_respostas(usuario,resposta,campo,formulario) values('$name','".strip_tags($val)."','$key','$row[id]')") or die(mysql_error());
}
}
?>
<form method="post" enctype="multipart/form-data" style="margin-bottom:5px">
<input type="hidden" name="acao" id="acao" value="<?php echo $row['id']; ?>" />
<?php
$get_form = mysql_query("SELECT * FROM cms_formularios_campos WHERE formulario = '$row[id]' ORDER BY ID") or die(mysql_error());
while($form = mysql_fetch_assoc($get_form)){
?><p><label class="label-form" for="<?php echo $form['id']; ?>"><?php echo $form['nome']; ?></label><br /><?php if($form['tipo'] == 'Resposta curta'){ ?><inputtype="text" name="<?php echo $form['id']; ?>" id="<?php echo $form['id']; ?>" class="input-form" /><br><?php if($form['obrigatorio'] == 'sim'){ ?><span style="color:red">* Requerido</span><?php } ?><?php } ?></p><input type="submit" class="input-form" value="Enviar" />