This is simple to solve, just leave only the quotes without the space and put the variables inside the function Trim (denied):
if (!trim($nome) or !trim($categoria) or !trim($rua) or !trim($numero) or !trim($bairro) or !trim($abre) or !trim($fecha) or !trim($email) or !trim($telefone)) {
echo"2 - Tente novamente</b>, faltou preencher corretamente um ou mais campos do formulário.";
}
A more complete form, in this way it checks whether it is null or empty:
function verificaCampos(array $campos){
foreach($campos as $campo){
if(empty(trim($campo)) or is_null(trim($campo))){
return false;
}
}
return true;
}
$nome = 'ok';
$categoria = 'ok';
$rua = 'ok';
$numero = 'ok';
$bairro = 'ok';
$abre = 'ok';
$fecha = 'ok';
$email = 'ok';
$telefone = 'ok';
$campos = [
$nome,
$categoria,
$rua,
$numero,
$bairro,
$abre,
$fecha,
$email,
$telefone
];
if (!verificaCampos($campos)) {
echo"Tente novamente</b>, faltou preencher corretamente um ou mais campos do formulário.";
}
It’s not very clear what your doubt is
– gabrielfalieri
Now the question got weird, I wanted to compare variable by variable. That was the question. @dvd solved.
– WillBill