Home > Backend Development > PHP Problem > How to get form submitted data in PHP

How to get form submitted data in PHP

(*-*)浩
Release: 2023-02-24 14:04:01
Original
5092 people have browsed it

How PHP gets the data submitted by the form

How to get form submitted data in PHP

##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 Data

Example: $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>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template