Click to See Complete Forum and Search --> : keeping checkboxes checked in PHP


MBussey24
09-05-2007, 08:53 PM
I'm trying to create a form with checkboxes. I have the results of the form appear on a results page. I'm having problems trying to figure out how to keep these checkboxes checked. Here's a sample of my code:

<form action="results.php" method="post">
Please check...
<input type="checkbox" name="inquiry[]" value="Inquiry" />

</form>

The results will be posted to results.php. How would I go about keeping these results checked on the results page?

sitehatchery
09-05-2007, 09:12 PM
<input type="checkbox" name="check1" value="1" <?php if($_POST['check1']) echo "checked"; ?> />

MBussey24
09-05-2007, 10:04 PM
Tried to use that script, only to get a Undefined index notice.

Yelgnidroc
09-06-2007, 05:03 AM
Try this:


<FORM ACTION="result.php" METHOD="POST" >
<input type="checkbox" name="check1" value="1" <?php if(isset($_POST['check1'])) echo "checked"; ?> />
<input type="checkbox" name="check2" value="2" <?php if(isset($_POST['check2'])) echo "checked"; ?> />
<INPUT TYPE="SUBMIT" name="submit" VALUE="Submit" class="submit">

</FORM>