php实例代码:获取checkbox复选框中的内容。
代码:
<html> <body> <form METHOD="POST" ACTION="DealWithArrayFormData.php"> <H1>联系人信息</H1> <TABLE> <TR> <TD>孩子们的名字:</TD> </TR> <TR> <TD><INPUT TYPE="TEXT" NAME="children[]"></TD> </TR> <TR> <TD><INPUT TYPE="TEXT" NAME="children[]"></TD> </TR> <TR> <TD><INPUT TYPE="TEXT" NAME="children[]"></TD> </TR> <TR> <TD><INPUT TYPE="TEXT" NAME="children[]"></TD> </TR> <TR> <TD><INPUT TYPE="TEXT" NAME="children[]"></TD> </TR> </TABLE> <BR> <BR> <BR> <INPUT TYPE="SUBMIT" VALUE="提交"> <BR> <BR> <INPUT TYPE="RESET" VALUE="Clear the Form"> </FORM> </BODY> </HTML> <!-- DealWithArrayFormData.php <?php foreach ($children as $index => $child){ echo "<BR>child[$index]=$child"; } echo "<BR>"; sort($children); foreach ($children as $index => $child){ echo "<BR>child[$index]=$child"; } ?> -->
2,收集表单数据的函数
<?php /** * 收集表单提交的数据 * by www.jb200.com */ function process_form($data) { $msg = "表单 {$_SERVER['PHP_SELF']} 提交的内容如下: nn"; foreach($data as $key=>$val) { $msg .= "$key => $valn"; } mail("test@jb200.com", "表单提交", $msg); } ?>