使用表单标签,使网站与用户发生数据交互,将用户输入的数据传送到服务器端。
语法:
<form method="传送方式" action="服务器文件"></form>
- method : 数据传送的方式(get/post)。
- action :浏览者输入的数据被传送到的地方,比如一个PHP页面(save.php)。
下面是一个示例:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>表单标签</title>
</head>
<body>
<form method="post" action="save.php">
<label for="username">用户名:</label>
<input type="text" name="username" id="username" value="" /><br>
<label for="pass">密   码:</label>
<input type="password" name="pass" id="pass" value="" /> <br>
<input type="submit" value="确定" name="submit" />
<input type="reset" value="重置" name="reset" />
</form>
</body>
</html>
注意:
所有表单控件(文本框、文本域、按钮、单选框、复选框等)都必须放在 标签之间。