my channels
business · cars · dieting · diy · dogs · etiquette · fitness · frugal living · green living · health · home business · home improvement · jobs · parenting · self help · travel
more

how to, business, education, diy, technology, internet, small business, computers, google, social networking, search engine optimization, internet search, internet traffic,
how to
business
search engine optimization
internet search
internet traffic
more...

An Easy Way to Add a Search Bar to Your Web Site or Blog


RELATED ARTICLES
5 tips on using web search engines to find what you want
10 Easy steps to keep your PC healthy with Windows XP
How to Digg our way to the top: a challenge for all Factoidz writers

Your web site or blog has several dozen links to on-site articles, entries and various other pages, and now you want to install a basic SEARCH BAR that will by using keyword inquires, return these pages from only your site.

You can write your own complicated code of course and deal with server-side coding and database issues, or you can use this easy way to get your page links returned on SEARCH using the strength of Google’s search engine.

Let’s call the site called “www.MY-SITE.com” that you want to add a SEARCH bar to. Visitors to “MY-SITE.com” are greeted by the page “index.html” as per the normal manner of web pages. This is the page that you want to have a SEARCH bar on. This is your main or home page where all the links to other pages and documents in your site are listed either in a navigation bar or as a list of title links to other pages.

First Step : Create a Simple FORM for your index.html Page

In your html document “index.html” where you want your SEARCH bar to appear, place the following code: (without the white space after/before the angle-brackets)

< form action=”google.php” method=”post” >

< input type=”text” name=”search” />

< input type=”submit” value=”Search” />

< /form>

Style the form however you wish with padding, width, margin, etc. Let’s add some style to this, as follows: (again, without the white space after/before the angle-brackets)

< form action=”google.php” method=”post” style=”width:300px; margin:0 auto 3px;” >

< input type=”text” name=”search” style=”width:230px; border:1px solid silver; padding:2px 2px 6px” />

< input type=”submit” value=”Search” />

< /form >

This will give a length of 300 pixels and will be centered on your page. This “300px” allows for the width of the input bar PLUS the width of the “submit” button that we are creating with input type=”submit” value=”Search” and for good measure, a few pixels left over.

The user-input box (SEARCH box) will be 230 pixels wide and have a 1-pixel silver border around it and a visually pleasing padding around the blank space where the user will type in the text s/he wishes to search for. SAVE this page with the current name “index.html” and upload this to your domain “www.MY-SITE.com.”

Next you need to create a *php document that we will call “google” since we are using the Google search engine for the SEARCH bar.

Second Step : Create a PHP Document

Open a blank document in your html or text-editor and paste the following code with no other text or comments on the page. Don’t try to re-type it, it is too easy to make an error :

< ?

$website = “www.MY-SITE.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”);

? >

(again, without the ‘white space’ between the opening “<” and “?” &  closing “?” and  “>“)

Note the first line which cites your domain “www.MY-SITE.com.” This is important as it will instruct Google from where to SEARCH for pages to return upon user request.

SAVE this short document as “google.php” and upload this to the same directory as your “index.html” page. Make sure that your html editor or host does not change the extension by default to “google.php3” as this will not work. The page must end with *php. If it is changed to *php3, manually rename the extension to be “.php

We’re done with this part now.

Next, we have to submit your domain (”www.MY-SITE.com”) to Google to get your links indexed and make this “SEARCH FORM” work. For Google to return results from your page, googlebot must first crawl & index all the links and pages in your domain from the information in the *php page that you created (specifically, from the information provided in the first line $website = “www.MY-SITE.com”; of the document “google.php”)

Your site may already be indexed by Google and this next step may be unnecessary but it is better to suggest it anyway and get this working as soon as you can.

Third Step : Submit Your Site URL to Google

screen capture of the addURL-to-Google web page

(screen capture image by author)

Go to http://www.google.com/addurl/ and add your domain URL (in this case, www.MY-SITE.com, complete with the "http://” as per instruction) to the URL box, shown in the image and link given above, and submit it (the submit button of this page not shown in this image.)

Now, wait a few days for googlebot to find and index your site and all the URLs therein. It is not guaranteed that Google will in fact index your pages but it is highly probable that Google will do so. From their site, Google says this on the matter of crawling/indexing your suggested URL:

“Only the top-level page from a host is necessary; you do not need to submit each individual page. Our crawler, Googlebot, will be able to find the rest. Google updates its index on a regular basis, so updated or outdated link submissions are not necessary. Dead links will ‘fade out’ of our index on our next crawl when we update our entire index. “

Googlebot will find “index.html” in the suggested URL “www.MY-SITE.com” and, if it is deemed worthy, crawl and index all (or many/most) of the links therein. You do not have to submit every link on the index page to Google. It will find them and know of their existence in time, and any URL links removed from “index.html” will eventually be ‘dropped’ from these indexes as well.

Within a few days, the SEARCH bar on your site will return a URL result on any searched term that is a match and only from the links that exist in your site. This is a fairly easy way to install a SEARCH bar feature to your site without having to do extensive backend coding and it gets your pages indexed fairly fast. Being ‘found’ on Google is helpful in its own right, and this makes your pages be ‘SEARCHable’ from your site.

I hope you find this tutorial useful.


ABOUT THE AUTHOR
thestickman
Web Page Builder/Designer
Toronto, ON CANADA

MY STATISTICS
Level : Fz Guide  [?]
77 Factoids published
38 followers & subscribers
+ 193 positive votes
MY EXPERT RANKINGS
#2 in education
#9 in diy
#4 in learning
ABOUT THIS ARTICLE
0 comments
Published 2 months ago
+ 1 positive votes
SHARE THIS ARTICLE



NEW ARTICLE ALERTS
Sign up for notifications when new knowledge articles are published in topics relating to this article:
 how to
 business
 education
 diy
 technology
 internet
 small business
 computers
Email address:

Get published. Earn money. Gain Web cred.
Apply for a writer's account on Factoidz.

Related Articles
Hiring a Search Engine Optimizer (SEO) - Do's and Don'ts

How Search Engines Work: Search Engine Optimization

Mega Importance of Meta Tags in Search Engine Optimization

Internet startups: Why now is the right time to build a social networking site

I’m a Self-employed Grandparent; Can I Add my Grandchildren to My Health Insurance Policy?

Microsoft Plays Catch-Up In Race of Web Platform

How to store your data backups the right way

GoDaddy, Yahoo! Small Business or MyDomain? Evaluating your web hosting options.

BlueHost.com: A Review

VistaPrint vs. 123Print: online printing review (print quality, delivery, and customer service)

Republish this article [?]
You may republish this article with proper attribution to the author and Factoidz.
Click to highlight the text, then press Control+C to copy to your clipboard
Popular in How To
Budgeting: LEARNING to Take Control of Your Money

How good is Your Memory and How Can We improve It: A Trick to Keep Yourself From Getting Angry.

Screen Printing At Home Made Easy

How to use tells to improve your Poker game

How to make a Michael Jackson Thriller costume

How to Make Alcohol: an extremely cheap, fast, and easy way to make decent quality alcoholic beverages

View more How To articles
Popular in Business
Ideas for fun and unconventional jobs with a good salary

How to Impress Your Golfing Buddies with your Golf Etiquette Knowledge

Businesses partnering with PEO's can reap rewards in a down economy

Credit Checks: the Good, the Bad, and the Ugly

How to Find a Job as an Overseas Contractor

Using writer's guidelines effectively

View more Business articles
More Related
The Goal of Search Engine Optimization (SEO)

SEO: Raise Your Ranks In Search Engines With Backlinks

5 Web Marketing Strategies To Promote Your Online Business And Increase Website Traffic

Do You Really Know How To Search The Internet? Tips For More Effective Searching.

How To Search The Internet Seriously

How to set up an data backup service such as Carbonite or Mozy

Will I get high-quality printed marketing brochures by using an online printer?

BlueHost.com: A Review

Comments & Questions
Leave comment
You can sign in to comment under your Factoidz account.

Your name:

Email address:

Homepage (optional):

Comment:

Notify me of new comments