- <?php
- if ($_POST[’submit’])
- {
- print_r($_POST);
- echo ‘<br>文本:’ . $_POST[’txt’];
- echo ‘<br>单选:’ . $_POST[’radio’];
- echo ‘<br>下拉单选:’ . $_POST[’select0′];
- echo ‘<br>下拉多选:’;
- if (!emptyempty($_POST[’check’]))
- {
- echo ‘<br>(1)’;
- $arr = $_POST[’check’];
- $arr_sise = count($arr);
- for($i=0; $i<$arr_sise; $i++)
- echo $arr[$i] . “ ”;
- echo ‘<br>(2)’;
- for($i=0; $i<count($_POST[’check’]); $i++)
- echo $_POST[’check’][$i] . “ ”;
- echo ‘<br>(3)’;
- foreach ($_POST[’check’] as $chk)
- echo $chk . ‘ ’;
- }
- echo ‘<br>多行选择:<br>’;
- foreach ($_POST[’select’] as $sel)
- echo $sel . ‘ ’;
- echo ‘<br><br>遍历所有值:’;
- foreach ($_POST as $key=>$postval) //$_POST 写为 $_POST[] 是错误的
- {
- if (is_array($postval))
- {
- echo “<br>”;
- foreach ($postval as $k=>$v) //$postval 写为 $postval[] 是错误的
- echo $v . ‘ ’;
- }
- else
- {
- echo “<br>”;
- echo $postval . ‘ ’;
- }
- }
- echo ‘<br>’ . str_repeat(’- ‘, 30);
- }
- ?>
- <form name=”frm1″ method=”post” action=”action.php”>
- 文本:<input name=”txt” type=”text” value=”">
- <br><br>
- 单选框:
- <input name=”radio” type=”radio” value=”radio1val”>radio1
- <input name=”radio” type=”radio” value=”radio2val”>radio2
- <br><br>
- 多选框:
- <input name=”check[]” type=”checkbox” value=”val of check1″>check1
- <input name=”check[]” type=”checkbox” value=”check2val”>check2
- <br><br>
- 下拉单选:
- <select name=”select0″>
- <option value=”0″></option>
- <option value=”01″>第01行</option>
- <option value=”02″>第02行</option>
- <option value=”03″>第03行</option>
- <option value=”04″>第04行</option>
- <option value=”05″>第05行</option>
- <option value=”06″>第06行</option>
- </select>
- <br><br>
- 下拉多选:
- <select name=”select[]” multiple size=”5″>
- <option value=”0″></option>
- <option value=”1″>第一行</option>
- <option value=”2″>第二行</option>
- <option value=”3″>第三行</option>
- <option value=”4″>第四行</option>
- <option value=”5″>第五行</option>
- <option value=”6″>第六行</option>
- </select>
- <br><br>
- <input name=”submit” type=”submit” value=”提交”>
- </form>