1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<form action="page2.php" method="post"> <div> <h4>Radio Button Choice</h4> <label for="radio-choice-1">Choice 1</label> <input type="radio" name="radio-choice-1" id="radio-choice-1" tabindex="2" value="car" /> <label for="radio-choice-2">Choice 2</label> <input type="radio" name="radio-choice-2" id="radio-choice-2" tabindex="3" value="van" /> <label for="radio-choice-1">Choice 3</label> <input type="radio" name="radio-choice-3" id="radio-choice-3" tabindex="2" value="lorry" /> <label for="radio-choice-2">Choice 4</label> <input type="radio" name="radio-choice-4" id="radio-choice-4" tabindex="3" value="plane" /> <label for="radio-choice-1">Choice 5</label> <input type="radio" name="radio-choice-5" id="radio-choice-5" tabindex="2" value="train" /> <label for="radio-choice-2">Choice 6</label> <input type="radio" name="radio-choice-6" id="radio-choice-6" tabindex="3" value="scooter" /> </div> <div> <input type="submit" value="Submit" /> </div> </form> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<?php $element1 = $_POST['radio-choice-1']; $element2 = $_POST['radio-choice-2']; $element3 = $_POST['radio-choice-3']; $element4 = $_POST['radio-choice-4']; $element5 = $_POST['radio-choice-5']; $element6 = $_POST['radio-choice-6']; $results=array(); if($element1 == "car"){ array_push($results, "car"); } if($element2 == "van"){ array_push($results, "van"); } if($element3 == "lorry"){ array_push($results, "lorry"); } if($element4 == "plane"){ array_push($results, "plane"); } if($element5 == "train"){ array_push($results, "train"); } if($element6 == "scooter"){ array_push($results, "scooter"); } $results = join(' ', $results); echo $results; |
In some cases this may work for you
1 2 3 4 5 6 7 |
if(!empty($_GET['checklist'])) { foreach($_GET['checklist'] as $check) { $check; //echo to see all passed values } }// end if |