title: How do i allow blank fields to be accepeted by my database as null?
body: <p>I have a simple html form and a php file.  The form works fine and when every field is filled out the form successfully submits the data to my database...but when i submit the form with an blank empty field i get an error saying that field was not received.  How do i get my database to accept a blank field as null?</p>
  
  <p><strong>HTML FORM</strong></p>
  
  <pre><code>&lt;form action="/tst/contact_form.php" class="well" id="contactForm" method="post" name="sendMsg" novalidate=""&gt;
  &lt;table align="center" border="0" cellpadding="1" cellspacing="1" height="75" width="653"&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
              &lt;div class="control-group"&gt;
              &lt;div class="controls"&gt;&lt;input class="form-control" data-validation-required-message="Please enter your name" id="name" name="itemname" placeholder="ITEM NAME" required="" type="text" /&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;/td&gt;
              &lt;td&gt;
              &lt;div class="control-group"&gt;
              &lt;div class="controls"&gt;&lt;input class="form-control" data-validation-required-message="Please enter your phone number" id="phone" name="qty" placeholder="QTY" required="" type="text" /&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;/td&gt;
              &lt;td&gt;
              &lt;div class="control-group"&gt;
              &lt;div class="controls"&gt;&lt;textarea id="txta" cols="25" style="height: 23px;" class="form-control" data-validation-required-message="Please enter your question/concern" id="msg" name="notes" placeholder="NOTES" required="" rows="6" type="msg"&gt;&lt;/textarea&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;/td&gt;
              &lt;td&gt;
              &lt;div class="control-group"&gt;
              &lt;div class="controls"&gt;&lt;input class="form-control" data-validation-required-message="Please enter your email" id="email-address" name="stotal" placeholder="TOTAL" required="" type="text" /&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;div class="control-group"&gt;
  &lt;div class="controls submit-btn"&gt;&lt;button class="btn btn-primary" type="submit" value="Submit"&gt;Submit&lt;/button&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>contact_form.php</strong></p>
  
  <pre><code>&lt;?php
  
  define('DB_NAME', 'xxx');
  define('DB_USER', 'xxx');
  define('DB_PASSWORD', 'xxx');
  define('DB_HOST', 'xxx');
  
  $connection = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);
  
  if(!$connection){
  die('Database connection failed: ' . mysqli_connect_error());
  }
  
  $db_selected = mysqli_select_db($connection, DB_NAME);
  
  if(!$db_selected){
  die('Can\'t use ' .DB_NAME . ' : ' . mysqli_connect_error());
  }
  
  echo 'Connected successfully';
  
  if($_POST['itemname']){
      $itm = $_POST['itemname'];
  }else{
      echo "Item Name not received";
      exit;
  }
  if($_POST['qty']){
      $qty = $_POST['qty'];
  }else{
      echo "Qty not received";
      exit;
  }
  if($_POST['stotal']){
      $stotal = $_POST['stotal'];
  }else{
      echo "Suggested Total not received";
      exit;
  }
  if($_POST['notes']){
      $notes = $_POST['notes'];
  }else{
      echo "notes not received";
      exit;
  }
  
  $sql = "INSERT INTO seguin_orders (itemname, qty, stotal, notes) 
          VALUES ('$itm', '$qty', '$stotal', '$notes')";
  
  if (!mysqli_query($connection, $sql)){
  die('Error: ' . mysqli_connect_error($connection));
  }
  </code></pre>
  
  <p><a href="http://oi58.tinypic.com/sotwjq.jpg" rel="nofollow">http://oi58.tinypic.com/sotwjq.jpg</a></p>