title: saving simple checkbox boolean php
body: <p>Something basic but I don’t see why it doesn’t work
  I want to save the state of a checkbox in a database, type Boolean, if checked 1 else 0 here is my code:</p>
  
  <pre><code>&lt;input type="checkbox" name="stok"  value="1"
    &lt;?php if(isset($_POST['stok'])) echo "checked='checked'"; ?&gt;
  /&gt;
  &lt;?php
      if (isset($_POST['stok']) &amp;&amp; !empty($_POST['stok']) &amp;&amp; $_POST['stok'] === 'on')               
          $stok = 1;  
      else 
          $stok = 0;      
  
      mysql_query ("update tab set etat_vendu=$stok where id=$big");
  ?&gt;  
  
  //this is my var $stok=$row['stok'];   
  </code></pre>