title: HTML using a PHP script
body: <p>im new in php programming and ive a problem recently. I have 1 html page with a Search Box and a php script using for grep in a specific file on local host. This is what i want, when a user type string of char and click on enter that send a POST to modify my php var $contents_list, and grep all filename where the string is found.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?php
  
  $contents_list = $_POST['search'];
  $path = "/my/directory/used/for/grep";
  
  $dir = new RecursiveDirectoryIterator($path);
  $compteur = 0;
  
  foreach(new RecursiveIteratorIterator($dir) as $filename =&gt; $file) {
      $fd = fopen($file,'r');
      if($fd) {
          while(!feof($fd)) {
              $line = fgets($fd);
              foreach($contents_list as $content) {
                  if(strpos($line, $content) != false) {
  $compteur+=1;
                      echo "\n".$compteur. "  :  " . $filename. "  :  \n"."\n=========================================================================\n";
                  }
              }         
          }
      }
      fclose($fd);
  }
  
  ?&gt;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8" /&gt;
         &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form action="page2.php" method="post"&gt;
      &lt;INPUT TYPE = "TEXT" VALUE ="search" name="search"&gt;
  &lt;/form&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And when i go to my html page and type text in searchbar, that redirect me to my php script "localhost/test.php" and i have 500 internal error.</p>
  
  <hr>
  
  <p>So I want:</p>
  
  <p>To see result of the php script on the same html page, but i dont know how to do that :/</p>
  
  <p>And if the previous filename return was same like previous result, dont print it, to avoid double result.</p>
  
  <hr>
  
  <p>I hope its clear and youve understand what i want to do, so thanks for the people who want to help me    &lt;3</p>