PHP form Table conveys parameter detail study _php skills

Source: Internet
Author: User
Tags php form
Why, then? Because the processing of the form has two kinds of get and post, how to pass all the do parameters in both forms, and to get it in the background through the same way has been a very confusing problem, today after a few hours of experiments finally understand, special send this article.
Get form:
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<meta http-equiv= "Content-type" content= "TEXT/HTML;CHARSET=GBK"/>
<title> forms use Get method to pass values </title>
<body>
The value of the Parm parameter in the <!--action cannot be passed to action-get.php-->
<form action= "Action-get.php?parm=url-get" method= "Get" >
<p>
Name: <input type= "text" name= "name"/>
<!--hidden variable transfer value-->
<input type= "hidden" name= "hkey" value= "Hvalue"/>
<!--get form's hidden variable pass value can be obtained by $_get["Do"]-->
<input type= "hidden" name= "Do" value= "index"/>
<!--Submit the Name property is not set and does not appear in the URL-->
<input type= "Submit" value= "submitted"/>
</p>
</form>
</body>

PHP to process get forms:
Copy Code code as follows:

<pre>
<?php
The value of ECHO parameter name is obtained by \$_get to ". $_get[" name]. ",";
The value of ECHO parameter name is obtained by \$_post to ". $_post[" name]. ",";
The value of ECHO parameter name is obtained by \$_request to ". $_request[" name]. ". \ r \ n";
The value of the echo parameter parm is obtained by \$_get to ". $_get[" Parm "].", ";
The value of the echo parameter parm is obtained by \$_post to ". $_post[" Parm "].", ";
The value of echo "parameter parm is obtained by \$_request to". $_request["Parm". ". \ r \ n";
The value of the echo parameter hkey is obtained by \$_get to ". $_get[" Hkey "].", ";
The value of the echo parameter hkey is obtained by \$_post to ". $_post[" Hkey "].", ";
The value of echo "parameter hkey is obtained by \$_request to". $_request["Hkey". ". \ r \ n";
The value of the echo parameter do is obtained by \$_get to ". $_get[" Do ".
The value of the echo parameter do is obtained by \$_post to ". $_post[" Do ".
The value of echo "Do" is obtained by \$_request to ". $_request[" Do ".". \ r \ n ";
?>
</pre>

Processing result output:
The value of the parameter name is obtained by $_get to KJ, and the value of the parameter name is obtained by $_post, and the value of the parameter name is obtained by $_request for KJ.
The value of the parameter parm is obtained by $_get, and the value of the parameter parm is obtained by $_post, and the value of the parameter parm is obtained by $_request.
The value of the parameter hkey is obtained by the $_get as Hvalue, and the value of the parameter hkey is obtained by $_post, and the value of the parameter hkey is $_request by Hvalue.
The value of the parameter do is obtained by $_get to index, and the value of the parameter do is obtained by $_post, and the value of the parameter do is obtained by $_request to index.
POST form:
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<meta http-equiv= "Content-type" content= "TEXT/HTML;CHARSET=GBK"/>
<title> forms use post to pass values </title>
<body>
The parm and do parameters in the <!--action can be obtained in action-post.php $_get way-->
<form action= "Action-post.php?parm=url-post&do=index" method= "POST" >
<p>
Name: <input type= "text" name= "name"/>
<!--hidden variable transfer value-->
<input type= "hidden" name= "hkey" value= "Hvalue"/>
<input type= "Submit" value= "submitted"/>
</p>
</form>
</body>

PHP to process POST forms:
Copy Code code as follows:

<pre>
<?php
The value of ECHO parameter name is obtained by \$_get to ". $_get[" name]. ",";
The value of ECHO parameter name is obtained by \$_post to ". $_post[" name]. ",";
The value of ECHO parameter name is obtained by \$_request to ". $_request[" name]. ". \ r \ n";
The value of the echo parameter parm is obtained by \$_get to ". $_get[" Parm "].", ";
The value of the echo parameter parm is obtained by \$_post to ". $_post[" Parm "].", ";
The value of echo "parameter parm is obtained by \$_request to". $_request["Parm". ". \ r \ n";
The value of the echo parameter hkey is obtained by \$_get to ". $_get[" Hkey "].", ";
The value of the echo parameter hkey is obtained by \$_post to ". $_post[" Hkey "].", ";
The value of echo "parameter hkey is obtained by \$_request to". $_request["Hkey". ". \ r \ n";
The value of the echo parameter do is obtained by \$_get to ". $_get[" Do ".
The value of the echo parameter do is obtained by \$_post to ". $_post[" Do ".
The value of echo "Do" is obtained by \$_request to ". $_request[" Do ".". \ r \ n ";
?>
</pre>

processing result output:
The value of the parameter name is obtained by $_get, and the value of the parameter name is obtained by $_post to zkj, and the value of the parameter name is obtained by $_request to ZKJ.
The value of the parameter parm is obtained by the $_get as Url-post, and the value of the parameter parm is obtained by $_post, and the value of the parameter parm is $_request by Url-post.
The value of the parameter hkey is obtained by the $_get, and the value of the parameter hkey is hvalue by the $_post, and the value of the parameter hkey is obtained $_request by Hvalue.
The value of the parameter do is obtained by $_get to index, and the value of the parameter do is obtained by $_post, and the value of the parameter do is obtained by $_request to index.
Conclusion:
Get form values can be obtained by _get, but parameters set by the URL parameter of the action are always not available
Post form values can be obtained by _post, but parameters set by the URL parameter of the action can be obtained by _get to
The same variable can be obtained by _get, but in the Get form, the URL parameter of the action is set in the Post form by the hidden variable setting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.