html中的form表单的简单使用

HTML piniu 1169浏览 0评论

网站怎样与用户进行交互? 答案:使用HTML表单(form).
表单是可以把浏览者输入的数据传送到服务器端的程序(比如ASP,PHP)的HTML元素,
服务器端程序可以处理表单传过来的数据,从而进行一些动作.比如,bbs,blog的登陆系统,购物车系统等.

<form name="form1" method="post" action="doLogin.php">
        <fieldset>
                <legend>用户名:</legend>
                <label for="username">用户名:</label>
                <input name="username" type="text" />
        </fieldset>
        <fieldset>
                <legend>密码:</legend>
                <label for="password">密码:</label>
                <input name="passwd" type="password" />
        </fieldset>
</form>

注解:
form 标签 — 代表HTML表单
form标签是成对出现的,以<form>开始,以</form>结束

属性.
action — 浏览者输入的数据被传送到的地方,比如一个PHP页面(doLogin.php)
method — 数据传送的方法: get/post
enctype — 表示将数据发送到服务器时浏览器使用的编码类型: application/x-www-form-urlencoded(默认), multipart/form-data(上传图片/文件等一定要指定该编码类型)


发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • * 昵称:
  • * 邮箱: