PHP如何获取表单提交的数据
1、超全局数组变量:$_GET[]
描述:获取表单 method = “get” 提交的数据
举例:$username = $_GET[“username”];
2、超全局数组变量:$_POST[](推荐学习:PHP编程从入门到精通)
描述:获取表单 method = “post” 提交的数据
举例:$username = $_POST[“username”];
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META name="Generator" content="EditPlus"> <META name="Author" content=""> <META name="Keywords" content=""> <META name="Description" content=""> <style type="text/css"> </style> <script type="text/javascript"> </script> </HEAD> <BODY> <?php var_dump($_POST); //超全局变量,$_GET $POST (数组类型) if(isset($_POST["ac"]) && $_POST["ac"]=="login") //防止灌水,判断表单确实是自己的表单 { $username=$_POST["username"]; $userpwd=$_POST["userpwd"]; echo("用户名是:{$username},密码是:{$userpwd}"); } ?> <form name="form1" method="post" action=""> 用户名:<input type="text" name="username" /> 密码:<input type="password" name="userpwd" /> <input type="hidden" name="ac" value="login" /> <input type="submit" value="提交表单" /> </form> </BODY> </HTML>
以上是PHP如何获取表单提交的数据的详细内容。更多信息请关注PHP中文网其他相关文章!