Forum Moderators: coopster
<?php
if($chkbox=="on"){
$chkswitch="checked='checked' value='on'";
}
?>
<form method="post" action="<? echo $PHP_SELF;?>" name="anything">
<input type="checkbox" name="chkbox" <? echo $chkswitch;?>>
<input type="submit" value="Submit" name="submit">
</form>
I'm using this sending and receiving "chkbox" from a MYSQL database also. Everthing works great!
Welcome to WebmasterWorld.
<input type="checkbox" name="chkbox" <? echo $chkswitch;?>>
I use:
<input type="checkbox" name="chkbox" value="on" <? if($chkbox==="on") { echo "checked"; } ?>>
It just keeps things that effect the checkbox all in one place, so if I want to make adjustments I can find it easily.
Justin