Create a search engine in Php-Part 1


Hi guys,

i’m here come with some simple tutorial for the begineers in php.In the first part of this tutorial i’m gonna tell about the design view of the search engine.

STEP 1:  first create two files named index.php and search.php

Index.php is the file where we will have our form design view of the search engine.

Search.php is the file where we can provide the results of the searched terms in it.

STEP 2:

Lets start with the designing of the form in index.php

<html>

<body>

<h2>MY Search Engine</h2>

<form method=”get” action=”search.php” >

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

<input type=”submit” name=”submit”/>

</form>

</body>

</html>

If you followed my previous tutorials you all can know about the methods and actions i used in the form tag. I Used get method here to pass the values in the address bar.

STEP 3: In this step we can get the values from the previous index.php

Use the below code to get the data from index.php

<?php

//Get Data

$submit=$_GET[‘submit’];

//textbox value

$search=$_GET[‘search’];

//Checking the submit button is clicked or not

if(!$submit)

echo ” You didn’t enter any keyword”;

else

//Check  the keyword for atleast 2 -3 letters

if(strlen($search<3))

echo ” your String is too short to Search”;

else

echo “Your Keyword is”. $search;

?>

In the second part of the tutorial we will deal about the database and other stuffs.

Advertisements
About

Working For Cause Not For Applause

Tagged with: , , ,
Posted in PHP

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: