PHP form form parameter passing details study_PHP tutorial
Jul 21, 2016 pm 03:45 PM
Why? Because there are two types of form processing: GET and POST, it has always been a very confusing question how to pass the do parameters in both forms and obtain them in the same way in the background. Today, after several hours of experimentation, I finally I understand, so I’m posting this.
GET form:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns ="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gbk "/>
<title>The form uses the GET method to transfer values</title>
</head>
<body>
The value cannot be passed to action-get.php -->
<form action="action-get.php?parm=url-get" method="get">
<p> ;
="hkey" value="hvalue" />
hidden" name="do" value="index" /> value="Submit"/>
PHP for GET form:
Copy code
The code is as follows:
<pre>
echo "The value of the parameter name is obtained through $_GET as ".$_GET["name"]." ,";
echo "The value of the parameter name is obtained through $_POST as ".$_POST["name"]. " ,";
echo "The value of parameter do is obtained through $_GET as ".$_GET["do"]." ,";
echo "The value of parameter do is obtained through $_POST as ".$_POST[ "do"]." ,";
echo "The value of parameter do is obtained through $_REQUEST as ".$_REQUEST["do"]." .rn";
?>
</ pre>
Processing result output:
The value of parameter name is obtained as kj through $_GET, the value of parameter name is obtained as kj through $_POST, and the value of parameter name is obtained through $_REQUEST is obtained as kj.
The value of parameter parm is obtained through $_GET, the value of parameter parm is obtained through $_POST, and the value of parameter parm is obtained through $_REQUEST.
The value of parameter hkey is obtained through $_GET is hvalue, the value of parameter hkey is obtained through $_POST, and the value of parameter hkey is obtained through $_REQUEST as hvalue.
The value of parameter do is obtained as index through $_GET, and the value of parameter do is obtained through $_POST, parameter do The value is obtained as index through $_REQUEST.
POST form:
Copy code
The code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional .dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content- Type" content="text/html;charset=gbk"/>
<title>The form uses POST to pass values</title>
</head>
<body>
<!-- The parm and do parameters in action can be obtained through $_GET in action-post.php-->
<form action="action-post.php?parm=url- post&do=index" method="post">
Value-->
> >
Copy code
The code is as follows:
<?php echo "parameter The value of name is obtained through $_GET as ".$_GET["name"]." ,"; echo "The value of parameter name is obtained through $_POST as ".$_POST["name"]." ,";
echo "The value of the parameter name is obtained through $_REQUEST as ".$_REQUEST["name"]." .rn";
echo "The value of the parameter do is obtained through $_POST as ".$_POST["do"] ." ,";
echo "The value of parameter do is obtained through $_REQUEST as ".$_REQUEST["do"]." .rn";
?>
</pre>
Processing result output:
The value of parameter name is obtained through $_GET, the value of parameter name is obtained as zkj through $_POST, and the value of parameter name is obtained through $_REQUEST. zkj.
The value of parameter parm is obtained as url-post through $_GET, the value of parameter parm is obtained as url-post through $_POST, and the value of parameter parm is obtained as url-post through $_REQUEST.
The value of parameter hkey is obtained through $ _GET is obtained as, the value of parameter hkey is obtained as hvalue through $_POST, and the value of parameter hkey is obtained as hvalue through $_REQUEST.
The value of parameter do is obtained as index through $_GET, and the value of parameter do is obtained through $_POST as, The value of the parameter do is obtained as index through $_REQUEST.
Conclusion:
The GET form value can be obtained through _GET; but the parameters set through the url parameter of the action cannot always be obtained
The POST form value can be obtained Obtained through _POST; but the parameters set through the url parameter of the action can be obtained through _GET
The same variables can be obtained through _GET, but they are set through hidden variables in the GET form, and through action in the POST form. url parameter settings
http://www.bkjia.com/PHPjc/320280.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/320280.html
TechArticle
Why? Because there are two types of form processing: GET and POST, it has been very confusing how to pass the do parameters in both forms and obtain them in the same way in the background...

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

deepseek why can't you log in deepseek login portal

How To Set Up Visual Studio Code (VS Code) for PHP Development

Why can't the Bybit exchange link be directly downloaded and installed?

How do you parse and process HTML/XML in PHP?

PHP Program to Count Vowels in a String
