hi all im having a issue with non selected checkboxes
when i select checkboxes and hit submit they go into the database ok but the checkboxes that have not been selected are adding 0 to the database
code below:
<form action="addeventusers.php?evid=<?php echo $evid; ?>&u=<?php echo $u; ?>" method="post">
user 1 <input type="checkbox" name="user[]" id="user[]" value="'.$userid.'" />
user 2 <input type="checkbox" name="user[]" id="user[]" value="'.$userid.'" />
<input type="submit" name="submit" id="submit" value="submit" />
</form>
php submission:
<?php
if(isset($_POST['submit'])){
$checkbox = $_POST['user'];
$submit = $_POST['submit'];
if($submit){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "INSERT INTO ev_invites (event_id, userid) VALUES ('$evid', '$del_id')";
$result = mysql_query($sql);
}
if ($result) {
echo "done";
}
mysql_close();
}
}
?>
basically what i am looking for is a way to stop the non selected checkbox from inserting into the database