这篇文章主要介绍了关于php与web页面的交互,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
1.form表单默认情况下提交数据的方式为get方式。
2.php脚本用来处理表单数据的预定义变量是$_get,$_post(区分大小写)
代码示例:(特别注意复选框属性name的时候加数组)
simpletest.html
<!doctype html><html><head><meta charset="utf-8"><title>insert title here</title></head><body><form action="simpleform.php" method="post"> 用户名:<input type="text" name="username"><br> 密码:<input type="text" name="password"><br> <!-- 复选框 --> 学过的编程语言是:<br> <input type="checkbox" name="language[]" value="php">php <input type="checkbox" name="language[]" value="java">java <input type="checkbox" name="language[]" value="c#">c# <input type="checkbox" name="language[]" value="c++">c++<br> <input type="submit" value="提交" ></form></body></html>
simplefoem.php
<?phpif(!empty($_post["username"])){ if($_post["username"]=="zhangsan"&&$_post["password"]=="123"){ echo "欢迎您:".$_post["username"]."<br/>"; echo "学过的编程语言:"; foreach ($_post["language"] as $value){ echo $value; } }else { echo "用户名密码错误"; }} ?>
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注!
相关推荐:
关于php的aop思想的解析
php 7.1安装xhprof进行性能分析的介绍
以上就是php与web页面的交互的详细内容。