Html5表单
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <form> 用户名: <input type="text"> <br/> 密 码: <input type="password"> <br/> 你喜欢的水果有? 苹果<input type="checkbox"><!--复选框--> 西红柿<input type="checkbox"> 香蕉<input type="checkbox"> <br/> 请你选择性别: 男<input type="radio" name="sex"><!--单选框--> 女<input type="radio" name="sex"> <br/> <select><!--下拉列表框--> <option>www.baidu.com</option> <option>www.qq.com</option> <option>www.google.com</option> </select> <input type="button" value="提交"> <input type="button" value="确定"> </form> <textarea cols="30" rows="30">请在此填写个人信息</textarea> </body> </html>
与PHP的交互
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>表单与PHP交互</title> </head> <body> <form action="http://localhost/MyServer/service.php" method="post"> 用户名:<input type="text" name="name"> 密 码:<input type="password" name="password"> <br/> <input type="submit" value="提交"> </form> </body> </html>
<?php echo "username:".$_POST[‘name‘]."<br/>password:".$_POST[‘password‘];
时间: 2024-12-24 11:24:20