title: How to make sure all fields are filled in php?
body: <p>
  Hi.
  I am trying to write some php to export input to csv format. It works really well, except it doesn't check to make sure all fields are filled. How can I make sure they are all filled.</p>
  
  
  
  <pre><code>&lt;?php
  $txt = "report.csv";
  $fh = fopen($txt, 'a+');
  if (isset($_POST['firstname']) &amp;&amp; isset($_POST['lastname']) &amp;&amp; isset($_POST['version']) &amp;&amp; isset($_POST['description'])) { // check if both fields are set
     $first = $_POST['firstname'];
     $last =  $_POST['lastname'];
     $version = $_POST['version'];
     $description = $_POST['description'];
     $q = "\"";
     $c = ",";
     $check=$first.$last.$version.$descrption;
     $txt=$q.$first.$q.$c.$q.$last.$q.$c.$q.$version.$q.$c.$q.$description.$q;
     if (strpos($check, '"') !== false){
     echo file_get_contents("/quotes.html");
     } else {
     file_put_contents('report.csv',$txt."\n",FILE_APPEND); // log to data.txt
     echo file_get_contents("yay.html");
     exit();
     }
  } else {
  echo file_get_contents("notfilled.html");
  }
  
  ?&gt;
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>  &lt;form action="problem.php" method="POST"&gt;
      &lt;label for="fname"&gt;&lt;h3&gt;First Name&lt;/h3&gt;&lt;/label&gt;
      &lt;input type="text" id="fname" name="firstname"&gt;
  
      &lt;label for="lname"&gt;&lt;h3&gt;Last Name&lt;/h3&gt;&lt;/label&gt;
      &lt;input type="text" id="lname" name="lastname"&gt;
      &lt;label for="version"&gt;&lt;h3&gt;Version&lt;/h3&gt;&lt;/label&gt;
      &lt;select id="version" name="version"&gt;
        &lt;option value="0.1"&gt;0.1&lt;/option&gt;
        &lt;option value="0.2"&gt;0.2&lt;/option&gt;
        &lt;option value="Other"&gt;Other&lt;/option&gt;
      &lt;/select&gt;
      &lt;label for="description"&gt;&lt;h3&gt;Description&lt;/h3&gt;&lt;/br&gt;&lt;p1&gt;Please describe your problem with details. Explain what the problem is how to reproduce it.&lt;/label&gt;
      &lt;textarea id="description" name="description" style="height:100px"&gt;&lt;/textarea&gt;
  
      &lt;input type="submit" value="Submit"&gt;
    &lt;/form&gt;
  </code></pre>