title: List Files in a Dictory and store user choice
body: <p>I'm fairly new to php and html in general. I am working on a pop up window that list files within a subdirectory, allow user to select only one and then sends it to a c program through the use of a submit button.</p>
  
  <p>The problem is that I don't know how to allow user to select a file from a list and store said selection in a variable. </p>
  
  <p>The other two requirements is that:
  - The c program is in the parent directory
  - The only files to be listed are .txt files</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;h1&gt; Test&lt;/h1&gt;
  &lt;select name="test"&gt;
  &lt;?php
  $dir="./files";
  
  if (is_dir ($dir))
  {
      if ($dh = opendir($dir))
      {
          while (($file = readdir($dh)) != false)
          {
               if ($file != ".." &amp;&amp; $file != "." &amp;&amp; strtolower(substr($file,strrpos($file,'.') +1)) == 'txt)
                {
                     echo "option value =\"$file\"&gt; $file &lt;/option&gt;";
                 }
          }
      }
  }
  ?&gt;
  &lt;/select&gt;
  
  &lt;button = type="button" onclick="self.close()"&gt; Cancel &lt;/button&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am looking for ideas on how to implement this....</p>
  
  <p><strong>Edit:</strong> Added in what I tried to do. The part I'm trying to figure out is is: get selected value from drop list box, send to submit button. Not sure how to go from this. Probably from a lack of understanding.</p>
  
  <p>FYI, Sorry for not putting in the code before. </p>