HTML:
<form action="add.php" method="get" id="form">
<tr>
<td>SALE ITEM</td>
<td>
<input type="checkbox" name="saleItem" value="n" <?php if(isset($_GET['saleItem'])) { ?> checked="checked" value="y" <?php } ?> />
</td>
</tr>
</form>
PHP (add.php)
$sql=("INSERT INTO table (sale) VALUES ('" . $_GET['saleItem'] . "')");
if (!(mysql_query($sql))) { die ("could not query: " . mysql_error()); }
It always inserts an N regardless if it is checked. I would love if it inserted y based on if the checkbox is checked. I also tried to put the value="n" into an else after the if, but it always put N regardless as well (i removed the value="n" previous to the if when I did this), here is what I meant:
<input type="checkbox" name="saleItem" <?php if(isset($_GET['saleItem'])) { ?> checked="checked" value="y" <?php } else { ?> value="n" <?php } ?> />