So, you want to put a "Search This Site" button on your PHP3 sites? Well, unless all your pages are stored in a database (ugh!), there is no easy way to do this using PHP alone.
The solution is to use another program designed specifically for indexing and searching your site, and then use the results of that program in your PHP script.
When I first needed this functionality for a site I was designing for the SummerWorks Theatre Festival, I came across ht://Dig. For those who don't know, "The ht://Dig system is a complete world wide web indexing and searching system for a small domain or intranet. ... [It] is meant to cover the search needs for a single company, campus, or even a particular sub section of a web site."
This tutorial will cover the following steps needed to get these two great Open Source applications working together:
Indexing the Site
Building the Search Page
Performing the Search
Parsing and Displaying the Results
I'm not going to spend much time on this section, since the ht://Dig documentation can answer any questions much better than I can in this tutorial.
As of this writing, the latest version of ht://Dig is 3.1.0b4. The latest version can always be found at http://www.htdig.org.
Once you've downloaded the archive, and unzipped it, read the README and htdocs/install.html files for the latest information and instructions on how to install. I'm running Linux 2.0.35 and Apache 1.3.3, so your set-up may vary, but the first step is to run the configuration program.
You may then want to edit the CONFIG file. Specifically I changed these four settings to the following values: