表单:
info.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <div align="center"> <form action="result.php" method="post" name="myform" target="new" enctype="multipart/form-data"> <table border="1" width="500" cellpadding="2"> <caption>个人信息</caption> <tr> <td align="right">姓名:</td> <td><input name="name" type="text"></td> </tr> <tr> <td align="right">性别:</td> <td>男:<input name="sex" type="radio" value="man"> 女:<input name="sex" type="radio" value="woman"> </td> </tr> <tr> <td align="right">爱好:</td> <td> <p> <label> <input type="checkbox" name="like[]" value="book" id="like_0"> 看书 </label> <label> <input type="checkbox" name="like[]" value="walk" id="like_1"> 散步 </label> <label> <input type="checkbox" name="like[]" value="play" id="like_2"> 玩耍 </label> <label> <input type="checkbox" name="like[]" value="travel" id="like_3"> 旅游 </label> </p> </td> </tr> <tr> <td align="right">学历:</td> <td><select name="xueli"> <option value="xiaoxue">小学</option> <option value="chuzhong">初中</option> <option value="gaozhong">高中</option> <option value="daxue">大学</option> </select></td> </tr> <tr> <td align="right">照片:</td> <td><input name="photo" type="file"></td>//上传图片 </tr> <tr> <td colspan="2" align="center"><input name="submit" type="submit" value="提交"> <input name="submit" type="reset" value="重置"></td> </tr> </table> </form> </div> </body> </html>效果图:
服务器:
result.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <table border="1" width="300"> <tr> <td>姓名:</td> <td><?php echo $_POST["name"]?></td> </tr> <tr> <td>性别:</td> <td><?php echo $_POST["sex"]?></td> </tr> <tr> <td>爱好:</td> <td><?php $re = ""; if ($_POST ["like"] != null) { for($i = 0; $i < count ( $_POST ["like"] ); $i ++) { $re .= $_POST ["like"] [$i]; } } echo $re; ?></td> </tr> <tr> <td>学历</td> <td> <?php echo $_POST ["xueli"]; ?> </td> </tr> <tr> <td> <?php $path="./upload/".$_FILES["photo"]["name"]; move_uploaded_file($_FILES["photo"]["tmp_name"], $path); echo $path ?> </td> </tr> </table> </body> </html>
原文地址:http://blog.csdn.net/scboyhj__/article/details/40683111