Home > Article > Backend Development > How to get form submitted data in PHP
How PHP gets the data submitted by the form
##1. Super global array variable: $_GET[]
Description: Get the data submitted by form method = “get”Example: $username = $_GET[“username”];2. Super global array variable: $_POST[] (Recommended learning: PHP programming from entry to proficiency)
Description: Get form method = "post" Submit DataExample: $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>
The above is the detailed content of How to get form submitted data in PHP. For more information, please follow other related articles on the PHP Chinese website!