title: How to capture radio button value and send it to a PHP plain text file?
body: <p>So I looked up everywhere on Stackoverflow and other forums but couldn't find a solution to my problem. Here is the problem: </p>
  
  <p>Create an HTML file that asks the user a question to vote on. There should be a few options done using radio buttons. There should also be a button to submit their vote. When they vote, they should be sent to a PHP file (different from the HTML file with the question) that records their vote and shows them the vote totals so far. To store the votes, you can just use a text file on the server. Part of the output is shown below.</p>
  
  <p>I learned how to read and write things to the file. And for this, I am thinking I will have to read the text file every time since I have to keep track of each vote. But my problem is how can I send the individual values of radio buttons to the text file, because right now, what's happening is I can't select a radio button option with $_POST["first"] because you can select multiple radio buttons. And the only way to make it so that only one option can be selected is to give it the same name values to the radio buttons. </p>
  
  <p>Here is my code so far: 
  HTML
      
      
        
          </p>
  
  <pre><code>    &lt;/style&gt;
    &lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;Whats your favorite class.&lt;/p&gt;
    &lt;form action="brianaCounted.php" method="post"&gt;
      &lt;input type="radio" name="first" checked&gt; 256
      &lt;input type="radio" name="second"&gt; 349
      &lt;input type="radio" name="third"&gt; 359
      &lt;input type="submit" name="submit" value="submit"&gt;
    &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>&lt;?php
      if (isset($_POST['submit'])) {
          $first = 0;
          $second = 0;
          $third = 0;
  
          if (isset($_POST['first'])) {
              $first += 1;
          } else if (isset($_POST['first'])) {
              $second += 1;
          } else {
              $third += 1;
          }
          echo $first, $second, $third;
      }
  ?&gt;
  </code></pre>
  
  <p>Thank you in advance! </p>