html表单
表单用于获取不同类型的用户输入
常用的表单标签:
<form> 表单
<input> 输入域
<textarea> 文本域
<label> 控制标签
<fieldset> 定义域
<legend> 域的标题
<select> 选择列表
<optgroup> 选项组
<option> 下拉列表中的选项
<button> 按钮
测试代码如下
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>表单</title> </head> <body> <form> 用户名:<input type="text"> <br> 密码:<input type="password"> <br> 你喜欢的水果: <br> 苹果<input type="checkbox"> 雪梨<input type="checkbox"> 香蕉<input type="checkbox"> <br> 请选择性别: 男<input type="radio" name="sex">//名字要一样sex 女<input type="radio" name="sex"> <br> 请选择你的网站 <select> <option>http://www.linuxidc.com/Linux/2015-05/117796.htm</option> <option>http://www.openwrt.org.cn/bbs/forum.php?mod=viewthread&tid=17</option> <option>https://dev.openwrt.org.cn/wiki/OpenWrt编译教程</option> </select> <br> <textarea cols="30" rows="30">请在次填写个人信息</textarea> </form> </body> </html>
html与php通讯
html代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>表单与php交互</title> </head> <body> <form action="http://localhost/myservice/newService.php" method="post"> 用户名:<input type="text" name="name"> <br> 密 码:<input type="password" name="password"> <br/> <input type="submit" value="提交"> </form> </body> </html>
PHP代码:
<?php
echo "用户名:".$_POST['name']."<br>密码:".$_POST['password'];