Click here to Skip to main content
15,896,063 members
Articles / Desktop Programming / Win32

Making a Search Engine

Rate me:
Please Sign up or sign in to vote.
4.94/5 (51 votes)
3 May 2013CPOL6 min read 243.1K   27.6K   124  
This article discusses the making of a search engine.
<?
// check is url is in db
$lnk =htmlspecialchars( $_POST['link']);

 $link = mysql_connect('localhost', 'root', 'root')
    or die('Could not connect: ' . mysql_error());
	

mysql_select_db('crawler') or die('oops! seems like we have encounter some problem');

$query = "SELECT count(*) as 'count' ,state  FROM url_webpage where url like'".($lnk)."%' ;";
$result = mysql_query($query) or die('you can not use illegal charecter');


$line = mysql_fetch_array($result, MYSQL_ASSOC);
 $count=$line['count'];
 if ($count>0) 
    {
    if($line['state']==0)
	  { echo 'we have your site in our database and will be crawled very soon</br> your site priority hav been moved to the highest.';	  }
	elseif($line['state']==1)
	  {echo 'we are crawling currently your site';}
	elseif($line['state']==2)
	  {echo 'You site have already been crawled';}
	}
 else
 { mysql_free_result($result); 
 $query = "insert into url_webpage values('".md5($lnk)."','".$lnk."',0,null,0,4,' ');";
// echo $query;
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
echo 'Thank you for adding your site we will soon crawl your site.';
 }
 
// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);



?>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
India India
I just love coding. But due to my studies it became very tough for me to manage both.

Comments and Discussions