title: PHP search field - Search String through files
body: <p>I am trying to search a directory (upload) for file names that match the search form.</p>
  
  <p>I enter the word 'Bach' into the search field on my website. I would then like my script to search through all the files in the directory and display all of the files of which contain the word 'bach'.</p>
  
  <p>This is the code that I have come up with, of which I expected it to work. I cannot see any visual errors and was wondering if you could help me.</p>
  
  <p>At the moment, I am getting no results from the search.</p>
  
  <pre><code>if(isset($searchvalue))
  {
      $dir = opendir('upload/'); 
      while ($read = readdir($dir)) 
      {
          if ($read!='.' &amp;&amp; $read!='..') 
          { 
              if (stristr($searchvalue,$read))  //case insensitive
              {
                  echo '&lt;p&gt;&lt;a href="upload/'.$read.'"&gt;'.$read.'&lt;/a&gt;&lt;/p&gt;'; 
              }
          }
       }
       closedir($dir);  
  }
  </code></pre>