samedi 17 octobre 2015

MySQL - Checkboxes - 1 or 0

I'm trying to post a checkbox value to my MySQL database. For some reason this code does not work when checking whether the value is set to 0/1.

Could anybody point me in the right direction. I know how to POST up for normal text/select input types but am having real difficulty with checkboxes and radio buttons.

createNewsArticle.php - View

<br /> Featured
<input type="hidden" name="featured" value="0" />
<input type="checkbox" name="featured" value="1" checked />
<br />

createNewsArticle.php - Controller

$featured = isset($_POST['featured']) ? 1 : 0;




Aucun commentaire:

Enregistrer un commentaire