I have serious contempt for checkboxes no matter what I try they never seem 2 display even though everythin else is fine. I have 2 files. 1 is an html file where I put my checkboxes and is linked to the php file. The other ofcourse is a php file. Now it amounts to the html is where the data is inserted and the php file is the output.
html file code for checkbox
<p class="choice">
Please choose the confectionary you would like to buy
<br/>
liquorice:
<input type="checkbox" name="ch1" value="choc" <?PHP print $ch1; ?>/>
<br />
chocolate:
<input type="checkbox" name="ch2" value="liqu"<?PHP print $ch2; ?> />
<br />
lollipops:
<input type="checkbox" name="ch3" value="wine"<?PHP print $ch3; ?> />
<br/>
fruitgums:
<input type="checkbox" name="ch4" value="lolli"<?PHP print $ch4; ?> />
<br/>
<?php
$ch1 = 'unchecked';
$ch2 = 'unchecked';
$ch3 = 'unchecked';
$ch4 = 'unchecked';
if (isset($_POST)) {
if (isset($_POST)) {
$ch1 = $_POST;
if ($ch1 == 'choc') {
$ch1 = 'checked';
}
}
if (isset($_POST)) {
$ch2 = $_POST;
if ($ch2 == 'liqu') {
$ch2 = 'checked';
}
}
if (isset($_POST)) {
$ch3 = $_POST;
if ($ch3 == 'wine') {
$ch3 = 'checked';
}
}
if (isset($_POST)) {
$ch4 = $_POST;
if ($ch4 == 'lolli') {
$ch4 = 'checked';
}
}
}
?>
</p>
php file code for checkboxes
echo $ch1;
echo $ch2;
echo $ch3;
echo $ch4;
?>
All I need it to do is display the checkboxes selected/unselected when I submit the form. Can anyone help with this?
Just a quick note my attitude towards code is that I do everything I can do like showing addresses, submit buttons etc and then something I cant do I try everything I can come up with and research and if I still cant do it I post it. I also will never put whole assignment things on here because I would get kicked off my uni course if I did.