[HTML]<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search </title>
</head>
<body>
<form id="form1" name="form1" method="post" action="index.p hp">
<input name="Search_IN " type="text" id="Search_IN" maxlength="44" />
<input type="submit" name="SearchBTN " id="SearchBTN" value="Search" />
</form>[/HTML]
[PHP]<?php
$YourSearch=str tolower($_POST['Search_IN']);
$text=ucfirst($ YourSearch);
if($_POST['SearchBTN']){
if(!ereg("^[a-zA-Z ]{4,44}$",$YourS earch)){
echo "Please Wright Rorrect Data";
exit;
}else{
echo "Your Search results for {$text} is :<br />";
if ($handle = opendir('../Search')) {
while (false !== ($file = readdir($handle ))) {
if($file=="." || $file==".." || $file=="_notes" || $file=="Result. php" || $file=="index.p hp"){
//--------------------------------------------------------------
}else{
//get the files information
$All_Files .= $file."*";
$All_Files_Data =explode("*",$A ll_Files);
}
}
closedir($handl e);
}
}
for($i=0;$i<cou nt($All_Files_D ata);$i++){
if(is_file($All _Files_Data[$i])){
if(strchr(strto lower(file_get_ contents($All_F iles_Data[$i])),$YourSearch) ){
echo "<a href='$All_File s_Data[$i]'>$All_Files_Da ta[$i]</a><br />";
}
}else if(is_dir($All_ Files_Data[$i])){
echo "The dir is : {$All_Files_Dat a[$i]}<br />";
echo "<a href='$All_File s_Data[$i]'>$All_Files_Da ta[$i]</a><br />";
}
}
}
?>[/PHP]
[HTML]</body>
</html>[/HTML]
This code to search on my site but im having problem with the code,when the user search the site i need to tell the user if he did't fined any result.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search </title>
</head>
<body>
<form id="form1" name="form1" method="post" action="index.p hp">
<input name="Search_IN " type="text" id="Search_IN" maxlength="44" />
<input type="submit" name="SearchBTN " id="SearchBTN" value="Search" />
</form>[/HTML]
[PHP]<?php
$YourSearch=str tolower($_POST['Search_IN']);
$text=ucfirst($ YourSearch);
if($_POST['SearchBTN']){
if(!ereg("^[a-zA-Z ]{4,44}$",$YourS earch)){
echo "Please Wright Rorrect Data";
exit;
}else{
echo "Your Search results for {$text} is :<br />";
if ($handle = opendir('../Search')) {
while (false !== ($file = readdir($handle ))) {
if($file=="." || $file==".." || $file=="_notes" || $file=="Result. php" || $file=="index.p hp"){
//--------------------------------------------------------------
}else{
//get the files information
$All_Files .= $file."*";
$All_Files_Data =explode("*",$A ll_Files);
}
}
closedir($handl e);
}
}
for($i=0;$i<cou nt($All_Files_D ata);$i++){
if(is_file($All _Files_Data[$i])){
if(strchr(strto lower(file_get_ contents($All_F iles_Data[$i])),$YourSearch) ){
echo "<a href='$All_File s_Data[$i]'>$All_Files_Da ta[$i]</a><br />";
}
}else if(is_dir($All_ Files_Data[$i])){
echo "The dir is : {$All_Files_Dat a[$i]}<br />";
echo "<a href='$All_File s_Data[$i]'>$All_Files_Da ta[$i]</a><br />";
}
}
}
?>[/PHP]
[HTML]</body>
</html>[/HTML]
This code to search on my site but im having problem with the code,when the user search the site i need to tell the user if he did't fined any result.
Comment