Our Affiliates
In this tutorials, we are going to learn how to let users search your site, without building a search engine. This can be useful if your pages are all html, or you do not have the time to build your own website search engine. This won't work unless your pages are indexed by google, if they're not, you can go to here to add them to googles index.
First, we have to create our form, so users can search your site. Insert the following on your homepage, or wherever you want the search box to appear.
<form action="google.php" method="post">
<input type="text" name="search" />
<input type="submit" value="Search" />
</form>
Your users can enter their search terms, then they will be forwarded to the google search results via our php file.
Create a new document, name is google.php, and insert the following into it...
<?
$website = "www.project09.com";
$search = $_POST['search'];
$search = str_replace(" ","+",$search);
$search = stripslashes($search);
header("Location: http://www.google.com/search?q=site%3A$website+%22$search%22&btnG=Google+Search");
?>
When the user it taken to google.php the search terms are converted into a valid google url, and they are then transported to googles results page. A very easy way to add a search function to your website!
First, we have to create our form, so users can search your site. Insert the following on your homepage, or wherever you want the search box to appear.
<form action="google.php" method="post">
<input type="text" name="search" />
<input type="submit" value="Search" />
</form>
Your users can enter their search terms, then they will be forwarded to the google search results via our php file.
Create a new document, name is google.php, and insert the following into it...
<?
$website = "www.project09.com";
$search = $_POST['search'];
$search = str_replace(" ","+",$search);
$search = stripslashes($search);
header("Location: http://www.google.com/search?q=site%3A$website+%22$search%22&btnG=Google+Search");
?>
When the user it taken to google.php the search terms are converted into a valid google url, and they are then transported to googles results page. A very easy way to add a search function to your website!



