I have a search system where I search the users by filtering by: name, age and email. If I filter by name and age and email, everything happens fine, but if I filter only by age, for example, nothing is returned even though I try to bank the correct data. I think I'm doing it the wrong way, because I use the AND operator in the query, that is, I want the three to return true, but that's not quite what I want. I want to filter by: age, or by age and email, or by age and email and name.
<?php
$nome = addslashes($_GET['nome']);
$idade = addslashes($_GET['idade']);
$email = addslashes($_GET['email']);
$sql = $pdo->query("SELECT * FROM usuarios WHERE nome = '$nome' AND idade = '$idade' AND email = '$email' ");
?>