G Gian New member Sep 2, 2009 #1 I have a form and it contains checkboxes, when i click the submit button, the next php page should display the checkboxes that i selected. How do I do this? please help
I have a form and it contains checkboxes, when i click the submit button, the next php page should display the checkboxes that i selected. How do I do this? please help
C Chris H New member Sep 2, 2009 #2 Page1.php <form target="page2.php" action="post"> <input type="checkbox" name="option1" value="Milk"> Milk<br> <input type="checkbox" name="option2" value="Butter" checked> Butter<br> <input type="submit" value="press me" /> </form> -------------------------------------- page2.php <?php $milk = $_POST['option1']; $butter = $_POST['option2']; if($milk == 'checked') { echo "Milk<br />"; } if($butter == 'checked') { echo "Butter<br />"; } ?> that should work
Page1.php <form target="page2.php" action="post"> <input type="checkbox" name="option1" value="Milk"> Milk<br> <input type="checkbox" name="option2" value="Butter" checked> Butter<br> <input type="submit" value="press me" /> </form> -------------------------------------- page2.php <?php $milk = $_POST['option1']; $butter = $_POST['option2']; if($milk == 'checked') { echo "Milk<br />"; } if($butter == 'checked') { echo "Butter<br />"; } ?> that should work
C Chris H New member Sep 2, 2009 #3 Page1.php <form target="page2.php" action="post"> <input type="checkbox" name="option1" value="Milk"> Milk<br> <input type="checkbox" name="option2" value="Butter" checked> Butter<br> <input type="submit" value="press me" /> </form> -------------------------------------- page2.php <?php $milk = $_POST['option1']; $butter = $_POST['option2']; if($milk == 'checked') { echo "Milk<br />"; } if($butter == 'checked') { echo "Butter<br />"; } ?> that should work
Page1.php <form target="page2.php" action="post"> <input type="checkbox" name="option1" value="Milk"> Milk<br> <input type="checkbox" name="option2" value="Butter" checked> Butter<br> <input type="submit" value="press me" /> </form> -------------------------------------- page2.php <?php $milk = $_POST['option1']; $butter = $_POST['option2']; if($milk == 'checked') { echo "Milk<br />"; } if($butter == 'checked') { echo "Butter<br />"; } ?> that should work