title: Using an HTML checkbox to put 1 or 0 into a MySQL table
body: <p>I am using a simple HTML checkbox in a form to put a 1 for checked and a 0 for unchecked in a field called "subcheck" in a MySQL table.</p>
  
  <p>Does the checkbox default to 1 for "checked" and 0 for unchecked?  If not, how can I give it those values?</p>
  
  <p>Form:</p>
  
  <pre><code>&lt;div class="subcheck"&gt;&lt;INPUT TYPE=CHECKBOX NAME="subcheck"&gt;Click here to receive free money in the mail.&lt;P&gt;&lt;/div&gt;
  </code></pre>
  
  <p>In the file the form goes to:</p>
  
  <pre><code>$subcheck = $_POST['subcheck'];
  
  mysql_query("INSERT INTO submission VALUES (NULL, '$uid', '$title', '$slug', '$cleanurl', '$displayurl', NULL, '$subcheck')");
  </code></pre>
  
  <p>The MySQL table:</p>
  
  <pre><code>`submission` (
    `submissionid` int(11) unsigned NOT NULL auto_increment,
    `loginid` int(11) NOT NULL,
    `title` varchar(1000) NOT NULL,
    `slug` varchar(1000) NOT NULL,
    `url` varchar(1000) NOT NULL,
    `displayurl` varchar(1000) NOT NULL,
    `datesubmitted` timestamp NOT NULL default CURRENT_TIMESTAMP,
    `subcheck` tinyint(1) NOT NULL,
    PRIMARY KEY  (`submissionid`)
  )
  </code></pre>