SOURCE CODE:
<html><head><title></title></head><body>
<?
if ((isset($_POST['chk1'])) && (isset($_POST['favorite']))) {
$ck1=$_POST['chk1'];
$ck2=$_POST['favorite'];
} else {
$ck1="";
$ck2="";
}
?>
<? if (($ck1 == "") && ($ck2 == "")) { ?>
<form method="post" action="282ln08chkrad.php">
<h2>What colors do you like?</h2>
<input type="checkbox" name="chk1[]" value="red">red<br>
<input type="checkbox" name="chk1[]" value="blue">blue<br>
<input type="checkbox" name="chk1[]" value="green">green<br>
<input type="checkbox" name="chk1[]" value="black">black<br><br>
<h2>Which one is your favorite color?</h2>
<input type="radio" name="favorite" value="red">red<br>
<input type="radio" name="favorite" value="blue">blue<br>
<input type="radio" name="favorite" value="green">green<br>
<input type="radio" name="favorite" value="black">black<br><br>
<input type="submit" value="Submit" name="btnSubmit">
</form>
<? } else { ?>
<? if (count($chk1) !=0) { ?>
<h2>The number of colors you selected was: <? echo count($chk1) ?></h2>
<h2>The colors you like are (values selected check boxes):</h2>
<?
foreach ($_POST["chk1"] as $chk1)
{
echo $chk1 . "<br>";
}
?>
<? } ?>
<h2>Your favorite color was: <? echo $_POST['favorite'] ?></h2>
<? } ?>