1.文字及密碼空格

1_1.php
<FORM METHOD='post' ACTION='1_2.php'>
<input type='text' name='a'>姓名
<input type='password' name='b'>電話
<input type=submit value='確認送出'>
</form>

1_2.php
<?php
$a = $_REQUEST['a'];
$b = $_REQUEST['b'];
echo $a.":姓名<br>\n";
echo $b.":電話<br>\n";
?>
2.隱藏空格

2_1.php
<FORM METHOD='post' ACTION='2_2.php'>
<input type='hidden' name='a' value='10'>
<input type='hidden' name='b' value='20'>
<input type=submit value='確認送出'>
</form>

2_2.php
<?php
$a = $_REQUEST['a'];
$b = $_REQUEST['b'];
echo $a.":a<br>\n";
echo $b.":b<br>\n";
?>
3.選擇按鈕

3_1.php
<FORM METHOD='post' ACTION='3_2.php'>
<input type='radio' name='a' value='man'>男
<input type='radio' name='a' value='woman'>女
<input type=submit value='確認送出'>
</form>

3_2.php
<?php
$a = $_REQUEST['a'];
echo "性別:".$a."<br>\n";
?>
4.文字區塊

4_1.php
<FORM METHOD='post' ACTION='4_2.php'>
<TEXTAREA NAME='a' ROWS='20' COLS='20'></TEXTAREA>
<input type=submit value='確認送出'>
</form>

4_2.php
<?php
$a = $_REQUEST['a'];
echo "文字區塊內容:".$a."<br>\n";
?>
5.下拉式選單-單選

5_1.php
<FORM METHOD='post' ACTION='5_2.php'>
<SELECT NAME='a'>
<option>1
<option>2
</SELECT>
<input type=submit value='確認送出'>
</form>

5_2.php
<?php
$a = $_REQUEST['a'];
echo "下拉式選單內容:".$a."<br>\n";
?>
6.下拉式選單-單選

6_1.php
<FORM METHOD='post' ACTION='6_2.php'>
<SELECT NAME='a[]' multiple size=5>
<option>1
<option>2
<option>3
<option>4
<option>5
</SELECT>
<input type=submit value='確認送出'>
</form>

6_2.php
<?php
$a = $_REQUEST['a'];
for ($i=0;$i<count($a);$i++){
echo $a[$i]."-".$i."<BR>\n";
}
?>
7.核取方塊

7_1.php
<FORM METHOD='post' ACTION='7_2.php'>
<INPUT TYPE='checkbox' NAME='a[]' value='10'>
<INPUT TYPE='checkbox' NAME='a[]' value='20'>
<INPUT TYPE='checkbox' NAME='a[]' value='30'>
<input type=submit value='確認送出'>
</form>

7_2.php
<?php
$a = $_REQUEST['a'];
for ($i=0;$i<count($a);$i++){
echo $a[$i]."-".$i."<BR>\n";
}
?>




Last modified: Tuesday, 6 September 2011, 7:54 PM