表单标签<form>
表单标签是最常用的标签,用于与服务器端的交互.
<input>:输入标签:接收用户输入信息.
其中的type属性指定输入标签的类型.
form标签中常见的属性定义
action:指定表单组件数据发送的位置,如果没有定义action属性,那么默认提交到当前页面.
method:定义表单提交的方式.只有两种常用get,post.如果没有指定method,默认就是get提交方式.表单提交get和post区别
1,get会将提交的信息显示在地址栏上.
post不会将提交的信息显示在地址栏.
2,get对于敏感信息不安全,因为显示在地址栏
Post对于敏感信息安全,因为不显示
3,get因为是显示在地址栏中,而地址栏的信息数据量是有限的,所以不可以提交大数据.
post可以提交大体积数据.
4,get会将信息封装到请求行,也就是http请求消息头之前.
Post会将信息封装到请求体,也就是http请求消息头之后.请求体和请求头之间是通过空行来进行分隔的.
表单中常用type属性的值的例子
<!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>
<fieldset>
<legend>我的注册区域</legend>
<form>
<table border="1" bordercolor="#00CCCC" width="80%" cellpadding="10">
<tr>
<th colspan="2">我的注册表单</th>
</tr>
<tr>
<td width=50%"">用户名:</td>
<td><input type="text" name="user" /></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="psw" /></td>
</tr>
<tr>
<td>确认密码:</td>
<td><input type="password" name="repsw" /></td>
</tr>
<tr>
<td>性别</td>
<td><input type="radio" name="gender" value="nan" />男
<input type="radio" name="gender" value="nv" checked="checked"/>女
</td>
</tr>
<tr>
<td>技术:</td>
<td><input type="checkbox" name="tec" value="java" />JAVA
<input type="checkbox" name="tec" value="html" />HTML
<input type="checkbox" name="tec" value="css" />CSS
</td>
</tr>
<tr>
<td>国家:</td>
<td><select name="country">
<option value="">选择国家</option>
<option value="usa">美国</option>
<option value="cn" selected="selected">中国</option>
<option value="eng">英国</option>
</select>
</tr>
<tr>
<th colspan="2">
<input type="submit" name="submit" value="提交" width="30" />
<input type="reset" name="reset" value="清除数据" width="30"/>
</th>
</tr>
</table>
</form>
</fieldset>
</body>
</html>