1
The following is correct to validate whether input values are validated?
if(!empty($_POST))
{
if(filter_input(INPUT_POST, 'hemocomponenteBolsa', FILTER_VALIDATE_INT))
{
if(filter_input(INPUT_POST, 'grupoSanguineoBolsa', FILTER_VALIDATE_INT))
{
if(filter_input(INPUT_POST, 'fatorRHBolsa', FILTER_VALIDATE_INT))
{
if(filter_input(INPUT_POST, 'dtVencimento', FILTER_SANITIZE_STRING))
{
if(filter_input(INPUT_POST, 'statusBolsa', FILTER_VALIDATE_INT))
{
#CÓDIGO
}
}
}
}
}
else
{
$_SESSION['msg'] = "<div class='alert alert-danger'><b>Atenção!</b>
Falha ao cadastrar. (Erro 007)</div>";
header("Location: ../view/novaBolsa.php");
}
In the case here, I have removed several fields for the purpose of learning, but I have 12 inputs
to be received, then I would 12 times if(...)
, it is correct to do it the previous way or it would slow the system down?
Construct an array and validate all with a loop
– Isac