checkbox question
Posted: Sun Aug 01, 2004 9:58 pm
Hi, was hoping someone might be able to help me, as you can see below I have 4 checkboxes; I am trying to print out the options selected on page 2. The problem is that it prints the oposite to the onces selected. I was also wondering if there was a way of printing, "None selected" if none of the checkboxes where selected. I do not want to use an array as I have more than print planed for each selection.
Any ideas, thanks in advance.
zeroanarchy
Page1 test.php
Page2 Results.php
Any ideas, thanks in advance.
zeroanarchy
Page1 test.php
Code: Select all
<body>
<form name="form1" method="post" action="results.php">
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="checkbox" name="C1" value="Football"></td>
<td>Football</td>
</tr>
<tr>
<td><input type="checkbox" name="C2" value="Rugby"></td>
<td>Rugby</td>
</tr>
<tr>
<td><input type="checkbox" name="C3" value="Cricket"></td>
<td>Cricket</td>
</tr>
<tr>
<td><input type="checkbox" name="C4" value="Tennis"></td>
<td>Tennis</td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>Page2 Results.php
Code: Select all
<?php
//if (!isset($_POSTї'sports'])) {Print "You did not select any sports, you really should do some exercise!"; }
if (!isset($C1) == True){Print "Rugby was selected";}
if (!isset($C2) == True){Print "Footbal was selected";}
if (!isset($C3) == True){Print "Cricket was selected";}
if (!isset($C4) == True) {Print "Tennis was selected";}
?>