Is the following correct way to validate whether input values are valid?
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 removed several fields for learning effect, but I have 12 inputs
to be received, so I would have 12 times if(...)
, correct do the previous mode or would it cause the system to be slow?