I'm needing to be able to get a search bar to work in PHP using HTML. I have done some coding, but cannot fully grasp how to do it. What can I do to get the search bar to work? I am needing to be able to search for a last name and have it display the name. There is no set first name or last name, just the name of the person all in one (if that makes sense)
I have attached the files that I am using.

Can you please explain what isn't working as you would expect it to? Are you getting any error messages?

I see that in customer_search.php you have the code:

<form action="customer_search.php" method="post">

However, it looks like customer_search.php is meant to be called from within index.php, and never called directly. Therefore, the form action should be index.php.

Then on index.php, you would do something like:

if ($action == 'search_customers') {   
    $name = filter_input(INPUT_POST, 'name');
    $customers = get_customers_by_last_name($name);
}

When I go to do the changes that you said about then click on the button it shows this (picture below). I'm trying to get the search bar to search for a customers last name and then show in a table below their full name (which in the sql database is under first name and last name), their email address and their city. From there I should be able to click on a select button that is beside the customers information and it'll take me to the customer_display.php page where I can view all of their information.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.