Search Forms for Site Search
Below these forms, you'll find the terms of use and other info on how to use our indexer and site search forms to have an ad-free site search on your website. And it's free. The forms below are real, even though you cannot search with them on this page because we require that you use them only on your own website. It's simple to index your site and install our search form on any web pages you wish. The code is below.
Search form if you want to be able to choose between exact phrase search and a bunch of words searched for separately
Search form if you want to only be able to do a search for a bunch of words searched for separately
Search form if you want to only be able to do an exact phrase search
You may use our site search and site indexer codes on any site you want as long as you comply with our terms of use and as long as the site is not about terrorism, porn, hate, violence, treason, etc. The biggest requirements are that you leave the code the way you find it and not alter it in any way, except to put the CSS positioning wherever you need it to be on your page(s). The links in the search box code must remain exactly as they are and must NOT be changed to NOFOLLOW under any circumstances. Our internal CSS styles are in the head section and must be kept as is except for positioning. Put them wherever you want on your web pages, as long as they are visible on the page. Our indexer and site search are copyrighted and you must never sell them or in any way represent that the codes involved are yours—they belong to us.
Use of the Search Forms or Search Page
We suggest that the top search form (the one that allows the choice of words or phrases) be used on smaller websites of 100 or fewer pages, but if you want to avoid having users click a radio button to choose words or phrase, choose one of the other two search forms. If the website has 300 or more pages, you might want to use only the phrase search form to avoid "out of memory" or "timeout after 30 seconds" errors. You should be okay using the phrase search form with anything up to 1000 pages, since our tests with sites of 348 and 789 pages worked fine with the phrase search form. We tested the words search form with these two sites, and if you search for one word all is well. We also tested sites with 286, 240, 116, and 19 pages without problem although 3 or 4 words can occasionally be problematic using the words search form on the 286-page and 240-page sites. Sites under 100 pages didn't seem to mind using the words search form with 3 or 4 words, but once the pages got over 300 pages, the words search form would run out of memory occasionally with 3 or 4 words, and with some words (that the site had lots of) pairs even 2 words caused errors. All errors allowed the search page to go on to the next search (with fewer words next time) when we simply pressed the F5 page refresh key. We cannot absolutely know how the phrase search form will act once your site has over 789 pages—we've never tried it, but we know the words search form is inadvisable with this many pages.
Summary: here is our advice on what to use where:
- Under 100 pages: use either the top form or the search page whose script and tutorial are here: Free-Website-Search-Script.html
- From 100 to 300 pages: Use any form but limit words to 2 for the words search form
- From 300 pages up: Use only the phrase search form
The searches will go at least 3 levels deep if you have simple links like this: ../subfolder/subsubfolder/page.html. But if they do fancy stuff like ../folder1/../folder/page.html, our indexer will get confused and you'll get less indexed pages than you want. The searches are reasonably fast, and the results come back with the search words highlighted, not bolded like most search engines do.
The routines work well, and they also are sorted for relevance. This means that the results with the most word or phrase matches are displayed first and those with the least matches are displayed last.
The reason we chose not to display whole pages in search results is the same reason Google doesn't. Some pages are 10,000 or more characters long! It would be silly. So we display reasonable sections of the results pages (always a snippet 350 characters or less long), and if you search for either one or more words or a phrase, one search term will be the first word(s) in the search result, and always highlighted. If the snippet contains several searched-for words, they will all be highlighted.
The search instructions tell you, in regards to what you may enter: "No hyphens (-) or underscores (_) or Enter/Return allowed in search terms. Use letters, numbers, spaces and these: , . ? ! in searches." If you enter other characters, instead of being cursed with error messages you will find that the PHP script dumps all these illegal characters from search terms, leaving behind only allowed characters.
In addition to the 3 forms above, there is a complete search page that you may choose to use and here is a script and tutorial to use: Free-Website-Search-Script.html. It contains the search form with the word/phrase option and the PHP site search engine script as well. The same terms of use apply to this page as are listed above for search forms. Do not molest the link or add a NOFOLLOW attribute, etc., if you use these scripts.
So how do you use our scripts for indexing and searching and what does a MySQL database have to do with all this? That comes next.
Site Search Scripts, Site Indexing Scripts, and MySQL
The scripts for the Site Search forms are below in bold (there is also a required CSS section to add to the head tag of your web page in the CSS style area), and they run the PHP script search-website.php, whose script and tutorial are available on this page: site search on your website. The script for the Site Search Page is search-this-site.php, whose script and tutorial are available on this page: site search page for your website. The script for the Site Indexer is index-site.php, whose script and tutorial are available on this page: index your site so you can have a free site search on your website.
The bottom line here is that in order to have a site search on your website, you first have to index your site. What this means is that you run a script that will crawl through your website, grabbing most of the searchable text, and storing it in a MySQL database. Not stored are tags such as script, body, paragraph, head, CSS styles, JavaScript, etc. In fact NO tags are stored, nor is the data between most tags' start tag and end tag. But the content in the head tag's title and description is stored, and so is the page URL, and everything that isn't tags between start tags and end tags of body tags, paragraph tags, headings tags like <H1>, etc.
If we had one of those site searches that stores the site indexes in their database for you, we would do what they do: support the database hosting on their servers by the use of ads. But our free website indexing and site search scripts support ad-free search results, so therefore we require that you store the indexed site in a MySQL database on your server. Our css-resources.com website currently has nearly 16 MB of files on it, and 3.6 MB of these files are of the HTML, HTM, and PHP types that get indexed, and the rest is images, etc. When indexed into a database, these pages take up 4.2 MB on the server. The reason they take up slightly more space than the pages themselves is that the hundreds of links in the sidebar are indexed for every single page since they are part of the page content. Like most savvy webmasters, we use a PHP include on every page so that any changes required on the left sidebar with the links, the right sidebar with the ads, or the header area with the logo image require only one page change. So we need only store this sidebar and header data on one single page, and the PHP include pulls it in to every page before it is sent from the server to the browser. So even though the text we grab from every page when our indexer is indexing is smaller in size than the actual page file size, for indexing we include the HTML contents of the PHP include file, which is fairly large. There's really no way to avoid sidebar content during indexing (no other available site search indexer avoids such content either), nor would we want to since it is legitimate page content.
We store the page URL, title, description and content of each page in MySQL database table fields called pageurl, title, description and content. The db table is called sitepages. Perhaps you are nervous about this MySQL stuff. If so, you can cease worrying—we've got your back! MySQL is the most popular open source database around and it's easy to deal with. First, the basics: All decent servers let you have at least one MySQL database and at least PHP 5.2 or better (if yours has PHP 4, get them to update—both PHP and MySQL are FREE for them so don't buy excuses). You can put as many tables as you want in a database—subject to the amount of server space your host allots you. If you host your own db, so much the better. You simply go to your server control panel called cPanel, check that you are alloted at least one "SQL Database" in the sidebar (if not, contact the host ASAP), find the databases section, click on the MySQL Databases icon, run the video tutorial at the top of the next page, then create a db by simply naming it. If you see no evidence of a db, contact your host ASAP. If they have no db for you, lose this host ASAP and get a decent one! Anyway, after naming/creating your db, go lower on the page and assign at least one user and one password (make sure it is a strong one!). Select maximum permissions for each user name, save them, then—lower down the page—add these users to your newly named MySQL database.
Now you have to create your PHP configuration file called config.php. As you can see from that link, this is just a way to connect to your database by using your db name and a username and password. Once you FTP this file into your server in the public_html folder, with YOUR info in it, you are ready to use our scripts to index your site. The script will create your table in your new db for you automatically once you Submit the full website URL (with its filename at the end, such as index.html) in the indexing script you save and FTP from the page you will find here: index your site so you can have a free site search on your website. If something goes wrong, you did not enter your info correctly in the config.php file. Note that if your db is called Lotsastuff, you don't enter that as the db name. On our server, we'd enter cssres_Lotsastuff. On yours, you can tell the right name by going back to the database creation screen and, at the top, look at the Create New Database area and you'll see an input box that says New Database: cssres_ just before the input box. Except yours will be New Database: whatever_ instead. So in your config.php file, call your databasename: whatever_Lotsastuff or whatever your db is called. And the username is cssres_yourusername, or for you, whatever_yourusername. Give the actual username, not "yourusername". But the password is just the password—don't add any prefix. Easy enough, right? By the way, the variable names and values we gave things in our configuration file have "psbhost" in them but you can call your string variables anything you want—like the script below—as long as your values are correct for YOUR db. You could use the following and do fine—just make sure you put YOUR info in place of the data in quotes but leave the PHP variable names alone:
<?php
$emailaddress = "emailaddress"; //EDIT ME (totally optional)
$roothostname = "localhost"; //LEAVE ALONE
$username = "username"; //EDIT ME
$password = "password"; //EDIT ME
$databasename = "databasename"; //EDIT ME
mysql_connect("".$roothostname."","".$username."","".$password."") or die(mysql_error());
mysql_select_db("".$databasename."") or die(mysql_error());
?>
We suggest guidance from this site and/or this site for using phpMyAdmin.
To sum up, the db needs creation, as do the username and password, and you need to have a correct config.php file to connect you to the db by naming the db, username, and password. But it is the indexing script itself that will create a table in your db and put the data in it. You will find that a MySQL db multiplies exponentially the capabilities of PHP scripts, and PHP and MySQL are both FREE and relatively easy to interact with. Once you have a table created by indexing your site, check it out by clicking the phpMyAdmin icon in the Databases area of your cPanel. Is that cool or what?
THE CSS CODE TO ADD TO THE CSS STYLE PART OF YOUR WEB PAGE'S HEAD SECTION:
/* (c) copyright 2011 MCS Investments, Inc. (http://mcsii.biz/) */
.search1 {margin-left:180px;width:137px}
.search2 {margin-left:180px;width:137px}
.search3 {margin-left:180px;width:137px}
.t {text-align:center;height:13px;width:117px;border:1px solid black;color:white;font:normal 9px Verdana;background-color:#66f;margin:0 0 0 5px;}
a.h:link {color:white;text-decoration:none}
a.h:visited {color:white;text-decoration:none}
a.h:hover {color:red;text-decoration:underline}
a.h:active {color:white;text-decoration:none}
#submit {padding:0;width:118px}
/* end of code */
SEARCH FORM IF YOU WANT TO BE ABLE TO CHOOSE BETWEEN EXACT PHRASE SEARCH AND A BUNCH OF WORDS SEARCHED FOR SEPARATELY:
<!-- (c) copyright 2011 MCS Investments, Inc. (http://mcsii.biz/) -->
<div class='search1'><form method="post" action="search-website.php">
<table width="137" border="0" cellpadding="0" cellspacing="0" align="center">
<tr><td width="137"><input type="radio" name="searchtype" value="phrase" checked>phrase
<input type="radio" name="searchtype" value="words">words</td></tr>
<tr><td width='137'> <input name="search" type="text" size="17"></td></tr>
<tr><td> <input id='submit' name="retrieve" type="submit" value="Search this site"></td></tr>
<tr><td><div class='t'><a class='h' target='_blank' HREF="http://www.css-resources.com/Free-Website-Search-Script-and-Tutorial.html">Free Website Search</a></div></td></tr></table></form></div><!--end of code-->
SEARCH FORM IF YOU WANT TO ONLY BE ABLE TO DO A SEARCH FOR A BUNCH OF WORDS SEARCHED FOR SEPARATELY:
<!-- (c) copyright 2011 MCS Investments, Inc. (http://mcsii.biz/) -->
<div class='search2'><form method="post" action="search-website.php">
<table width="137" border="0" cellpadding="0" cellspacing="0" align="center">
<input type="hidden" name="searchtype" value="words">
<tr><td width='137'> <input name="search" type="text" size="17"></td></tr>
<tr><td> <input id='submit' name="retrieve" type="submit" value="Search this site"></td></tr>
<tr><td><div class='t'><a class='h' target='_blank' HREF="http://www.css-resources.com/Free-Website-Search-Script-and-Tutorial.html">Free Website Search</a></div></td></tr></table></form></div><!--end of code-->
SEARCH FORM IF YOU WANT TO ONLY BE ABLE TO DO AN EXACT PHRASE SEARCH:
<!-- (c) copyright 2011 MCS Investments, Inc. (http://mcsii.biz/) -->
<div class='search3'><form method="post" action="search-website.php">
<table width="137" border="0" cellpadding="0" cellspacing="0" align="center">
<input type="hidden" name="searchtype" value="phrase">
<tr><td width='137'> <input name="search" type="text" size="17"></td></tr>
<tr><td> <input id='submit' name="retrieve" type="submit" value="Search this site"></td></tr>
<tr><td><div class='t'><a class='h' target='_blank' HREF="http://www.css-resources.com/Free-Website-Search-Script-and-Tutorial.html">Free Website Search</a></div></td></tr></table></form></div><!--end of code-->