UPUPD技术论坛
标题:
【HTML基础】-3.10-使用表单标签form,与用户交互
[打印本页]
作者:
洛尘
时间:
2015-10-16 11:41
标题:
【HTML基础】-3.10-使用表单标签form,与用户交互
网站怎样与用户进行交互?
答案是使用HTML表单(form)。表单是可以把浏览者输入的数据传送到服务器端,这样服务器端程序就可以处理表单传过来的数据。
语法:
<form>:<form>标签是成对出现的,以<form>开始,以</form>结束。
2.action:浏览者输入的数据被传送到的地方,比如一个php页面(save.php)。
3.method:数据传送的方式(get/post)。
<form method="post" action="save.php">
<label for-"username">用户名:</label>
<input type="text" name="username" />
<label for="pass">密码:</label>
<input type="password" name="pass" />
</form>
复制代码
注意:
1.所有的表单控件(文本框,文本域,按钮,单选框,复选框等)都必须放在<form></form>标签之间(否则用户输入的信息可不会提交到服务器上哦!)。
2.method:post/get的区别,这一部分内容属于后端程序员考虑的问题。感兴趣的同学可以自行百度一下。
任务:
在下面的代码中加入代码:method="post" action="save.php"
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>表单标签</title>
</head>
<body>
<form>
<label for="username">用户名:</label>
<input type="text" name="username" id="username" value="" />
<label for="pass">密码:</label>
<input type="password" name="pass" id="pass" value="" />
<input type="submit" value="确定" name="submit" />
<input type="reset" value="重置" name="reset" />
</form>
</body>
</html>
复制代码
欢迎光临 UPUPD技术论坛 (http://bbs.upupd.com/)
Powered by Discuz! X3.2