title: passing values from php to html
body: <p>I want to pass values from my php code (in the same page) to my html - so I could print it out nicely </p>
  
  <p>here is my php function (it's in a while cause it needs to print out 3 lines from a text)</p>
  
  <pre><code>    if(sizeof($words)==1)
      {
          $single = new single;
          $docres = $single-&gt;find($words);
              $dir = "source";
              foreach ($docres as $key=&gt;$filename) {
                  $counter = 0; 
                  $file = $filename +1;
                  $handle = fopen($dir."/".$file.'.txt',"r");
                  if($handle)
                  {
                      while($counter &lt; 3)
                      {
                          echo fgets($handle);
                         //this is what i need to print in my html
                          $input = $_POST['input'];
                          $counter++;
                  }
              }
      }
  }
  </code></pre>
  
  <p>and here is my html</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt; 
          &lt;title&gt;serach engine&lt;/title&gt; 
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt;
      &lt;/head&gt; 
      &lt;body&gt;
          &lt;form action="" method="POST"&gt;
              &lt;center&gt; 
                  &lt;h1&gt; My Search Engine &lt;/h1&gt;
                  &lt;input type = 'text' size='90'  value='' name = 'search' &gt; &lt;br&gt; 
                  &lt;input type = 'submit' name = 'submit' value = 'Search source code' &gt;         
                 // &lt;input type="value" name="input" value="&lt;?php echo $input; ?&gt;"&gt;
              &lt;/center&gt; 
          &lt;/form &gt;
        //I would like to print it out here
          &lt;/div&gt;
      &lt;/body &gt; 
  &lt;/html &gt;
  </code></pre>
  
  <p>I searched over the web and saw a solution using $_POST but it didn't work for me...</p>