NYCPHP Meetup

NYPHP.org

[nycphp-talk] about check box

Ken Robinson kenrbnsn at rbnsn.com
Mon Jan 28 17:38:18 EST 2008


Quoting chad qian <nynj.tech at hotmail.com>:

>
> Hi,
>
> Here is my current code:
> <input type="checkbox" name="checkbox" value="1" checked="checked" />
>
> I want:
> When checkbox is checked,i want to insert the value"1" to mysql database.
> When checkbox is unchecked,i want to insert the value "0" to mysql database.

Only checked checkbox values are returned to your php script, so you  
have to do something like:

<?php
$insertval = (isset($_POST['checkbox']))?$_POST['checkbox']:'0';
?>

Ken




More information about the talk mailing list