I am creating a search form to allow a client to search the database for users by entering a first name, last name, birthdate or some combination thereof. The problem I am having is that I am not sure how to handle creating the where clause of the query when any of the fields are left blank much less how to bind paramaters that may not be present. Here is my search box.
<form action="manageUsers.php"method="POST">
<h3>Search Users</h3>
<label for="lastName">Last Name:</label>
<input type="text" name="lastName"><br>
<label for="firstName">First Name:</label>
<input type="text" name="firstName"><br>
<label for="birthdate">Birthdate:</label>
<input type="text" name="birthdate"><br>
<input type="submit" value="Search Users">
</form>
The only thing that I can think of is using some if statements to dynamically create the query based on whether a field is blank or not. I'm sure someone has an easy solution I don't know about or haven't thought of. Thanks