title: Simple HTML Form Data Collection
body: <p>I am relatively new to the HTML language, but managed to create a simple HTML form that points to a PHP file to collect the response data. However, the PHP script isn't collecting anything upon submit, yet isn't throwing an error. I'm wondering if anyone can spot an error in my code, or if they have a more elegant solution for collecting responses.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form action="form_save.php" method="POST"&gt;
    &lt;fieldset align="left"&gt;
    &lt;legend&gt;Demographics&lt;/legend&gt;
    &lt;p&gt;&lt;i&gt;To be completed by participant&lt;/i&gt;&lt;/p&gt;
    &lt;table&gt;
      &lt;tr&gt;
      &lt;td&gt;Name:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="name" size="40" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Age:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="age" size="40" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Sex:&lt;/td&gt;
      &lt;td&gt;
          &lt;br&gt;
          &lt;input type="radio" name="sex" value="male" checked&gt;Male
          &lt;br&gt;
          &lt;input type="radio" name="sex" value="female" checked&gt;Female
          &lt;br&gt;
          &lt;input type="radio" name="sex" value="other"&gt;Other&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Ethnicity:&lt;/td&gt;
      &lt;td&gt;
          &lt;br&gt;
          &lt;input type="radio" name="ethnicity" value="Hispanic/Latino" checked&gt;Hispanic/Latino
          &lt;br&gt;
          &lt;input type="radio" name="ethnicity" value="Not Hispanic/Latino" checked&gt;Not Hispanic/Latino
          &lt;br&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Race :&lt;/td&gt;
      &lt;td&gt;
        &lt;br&gt;
        &lt;input type="radio" name="race" value="African American" checked&gt;African American
        &lt;br&gt;
        &lt;input type="radio" name="race" value="Asian" checked&gt;Asian
        &lt;br&gt;
        &lt;input type="radio" name="race" value="American Indian / Native Alaskan" checked&gt;American Indian / Native Alaskan
        &lt;br&gt;
        &lt;input type="radio" name="race" value="Caucasian" checked&gt;Caucasian
        &lt;br&gt;
        &lt;input type="radio" name="race" value="Native Hawaiian or Other Pacific Islander" checked&gt;Native Hawaiian or Other Pacific Islander
        &lt;br&gt;
        &lt;input type="radio" name="race" value="other"&gt;Other
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;input type="submit" value="Submit"&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Your responses have been submitted.&lt;/title&gt;
      Thank you. You have now completed the survey.
    &lt;/head&gt;
    &lt;?php
      $data = array("name","age","sex","ethnicity","race");
  
      $file = "/demo.csv";
      $current = file_get_contents($file);
      $current .= "\n" . implode(",",$data);
      file_put_contents($file, $current);
      ?&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I should also note that the PHP code points to a .csv file that is also hosted on the server where these two files are located.</p>