From the author of

Performing a Search

With the site’s content indexed, it’s time to create the search engine itself. The search form just needs a text input, which I’d call terms. The form would be submitted to search.php. Normally search forms are submitted via GET.

NOTE

The search.php script is also available in the downloadable code.

The search page must first verify that something was provided in $_GET['terms']. Then the page should apply strtolower(), strip_tags(), and an escaping function to make the terms safe to use in a query:

After building up the query, execute it and fetch the results (see the search.php script for details). For this particular example, the end result (Figure 2) isn’t fancy, but the search engine works, which is the most important thing. It shouldn’t be too hard for you to add some flair to this structure. Naturally, you’d want to paginate the query results, too.