Home » Php » Php and mysql filter

Php and mysql filter

Posted by: admin October 29, 2018 Leave a comment

Questions:

I’m trying to create a filter in mysql and php. In my database, I have many fields like : name, phoneNumber, email… And even if I do something like

if(!empty($_POST['name'])){ 
$name=$_POST['name']
}
if(!empty($_POST['phoneNumber'])){ 
   $phoneNumber= $_POST['phoneNumber']
    }
if(!empty($_POST['email'])){ 
    $email=$_POST['email']
    }

If someone only enters the name field, how do I do to not include the other fields in the query?

$query=query("SELECT * FROM clients WHERE clientName=$clientName && phoneNumber=$phoneNumber && email=$email)
Answers: