为了一个句号,写了好多行的代码——值!(html 表单的处理)

个人信息表


<span style="font-size:18px;"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn">
 <head>
 <meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
  <title> 个人信息表 </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
 </head>

 <body>

<?php
	if(!empty($_POST)){
		$name = $_POST['name'];
		$password = $_POST['password'];
		$sex = $_POST['sex'];
		$age = $_POST['age'];
		$provice = $_POST['provice'];
		$hr = $_POST['hr'];
		$txt = $_POST['txt'];

		echo "<br />姓名:$name";
		echo "<br />密码:$password";
		echo "<br />性别:$sex";
		echo "<br />年龄:$age";
		echo "<br />籍贯:$provice";
		echo "<br />爱好:";
		//方法1
		//print_r($hr);
		//方法2
		//foreach($hr as $key => $value){
		//	echo $value.",";
		//}
		//方法3
		$len = count($hr);
		$str = "";
		for($i=0;$i<$len-1;$i++){
			$str .= $hr[$i].",";
		}
		$str .= $hr[$i]."。";
		echo $str;
		echo "<br />个人简介:$txt";
	
	}
?>


	<form name="form1" method="post" action="nunu.php">
	<table width=800 rules=all border=1 bordercolor=#ccc style="margin:0 auto;"bgcolor="white" cellpadding=4>
	<caption><h2>个人信息表</h2></caption>
	<tr>
		<td width=20% align="center">姓   名</td>
		<td><input type="text" name="name"></td>
	</tr>
	<tr>
		<td align="center">密   码</td>
		<td><input type="password" name="password"></td>
	</tr>
	<tr>
	<td align="center">姓   名</td>
	<td>
	<input type="radio" name="sex" value="男" checked="checked"/>男
	<input type="radio" name="sex" value="女" />女
	</tr>
	<tr>
	<td align="center">年   龄</td>
	<td><input type="text" name="age" maxlength="3" style="width:170px"></td>
	</tr>
	<tr>
		<td align="center">籍   贯</td>
		<td>
		省份:<select name="provice">
			<option value="北京">北京</option>
			<option value="上海">上海</option>
			<option value="天津">天津</option>
		</td>
	</tr>
	<tr>
		<td align="center">个人爱好</td>
		<td>
		<input type="checkbox" name="hr[]" value="绘画">绘画
		<input type="checkbox" name="hr[]" value="写作">写作
		<input type="checkbox" name="hr[]" value="健身">健身
		<input type="checkbox" name="hr[]" value="逛街">绘画
		<input type="checkbox" name="hr[]" value="绘画">逛街
		<input type="checkbox" name="hr[]" value="学习">学习
		<input type="checkbox" name="hr[]" value="舞蹈">舞蹈
		</td>
	</tr>
	<tr>
		<td align="center">自我评价</td>
		<td ><textarea cols="40%" rows="5" name="txt"></textarea></td>
	</tr>
	<tr>
		<td></td>
		<td><input type="submit" value="提交">
		<input type="hidden" name="zhr" value="1991"></td>
	</tr>
	</table>
 </body>
</html></span>







 

posted @ 2016-01-01 00:00  小小暮雨  阅读(350)  评论(0编辑  收藏  举报