PHP basic search engine [iframe]

Lets create a script that will let you search any of the popular search engines that use the GET method. Examples: Google, Yahoo, Bing etc. This script will display an iframe for your search service anywhere on your page. You can also make it so Google searches through your website only. Let’s get started:

Bais HTML form:

<form method="GET" action="search.php">
<input type="text" name="q" value="Search"> <input type="submit" value="Search">

How it works:

This will create an input that will let the user enter the search term. The submit button will post the information in the input area to search.php.

$q = $_GET['q']; //get it from the form
echo '<iframe src="'.$q.'"></iframe>'; //embeds iframe for search results from GOOGLE.

How it works:

Using the GET method this script will GET the $q that was posted earlier using the HTML form. Using echo we show an iframe. This iframe will show the search results from Google on your website. This is achived by replacing the ?q variable of the search engine and adding $q which is the search term. Some other sources for search engines:

Yahoo –;.$q.’

Bing –;.$q.’&go= –;.$q.’&search=&qsrc=0&o=0&l=dir


About Eating Sharks
Born, etc.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: