PHPform parameter passing details _ PHP Tutorial

Source: Internet
Author: User
PHPform parameter details. Why? Because there are two types of form processing: GET and POST, how to pass the do parameter in both forms, in addition, it is always confusing to obtain data in the same way in the background. why? Because there are two types of form processing: GET and POST, how to pass the do parameter in both forms, in addition, it has always been a confusing issue to obtain data in the same way in the background. after several hours of experimentation, I finally understood this article.
GET form:

The code is as follows:


Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>



Use GET to pass values in a form







PHP for processing GET forms:

The code is as follows:


 
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 the parameter name is obtained through \ $ _ REQUEST as". $ _ REQUEST ["name"]. ". \ r \ n ";
Echo "the value of parm is obtained through \ $ _ GET as". $ _ GET ["parm"]. ",";
Echo "the value of parm is obtained through \ $ _ POST as". $ _ POST ["parm"]. ",";
Echo "the value of parm is obtained through \ $ _ REQUEST as". $ _ REQUEST ["parm"]. ". \ r \ n ";
Echo "the hkey value is obtained through \ $ _ GET as". $ _ GET ["hkey"]. ",";
Echo "the value of the hkey parameter is obtained through \ $ _ POST as". $ _ POST ["hkey"]. ",";
Echo "the value of the hkey parameter is obtained through \ $ _ REQUEST as". $ _ REQUEST ["hkey"]. ". \ r \ n ";
Echo "the do value of the parameter is obtained as". $ _ GET ["do"]. ",";
Echo "the do value of the parameter is obtained as". $ _ POST ["do"]. ",";
Echo "the do value of the parameter is obtained through \ $ _ REQUEST as". $ _ REQUEST ["do"]. ". \ r \ n ";
?>


Processing result output:
The value of the parameter name is obtained as kj through $ _ GET, the value of the parameter name is obtained through $ _ POST, and the value of the parameter name is obtained as kj through $ _ REQUEST.
The value of parm is obtained through $ _ GET, the value of parm is obtained through $ _ POST, and the value of parm is obtained through $ _ REQUEST.
The hkey value is obtained as hvalue through $ _ GET. the hkey value is obtained through $ _ POST, and the hkey value is obtained as hvalue through $ _ REQUEST.
The do value of the parameter is obtained as index through $ _ GET, the do value of the parameter is obtained through $ _ POST, and the do value of the parameter is obtained as index through $ _ REQUEST.
POST form:

The code is as follows:


Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>



The form uses POST to pass values.







PHP for processing POST forms:

The code is as follows:


 
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 the parameter name is obtained through \ $ _ REQUEST as". $ _ REQUEST ["name"]. ". \ r \ n ";
Echo "the value of parm is obtained through \ $ _ GET as". $ _ GET ["parm"]. ",";
Echo "the value of parm is obtained through \ $ _ POST as". $ _ POST ["parm"]. ",";
Echo "the value of parm is obtained through \ $ _ REQUEST as". $ _ REQUEST ["parm"]. ". \ r \ n ";
Echo "the hkey value is obtained through \ $ _ GET as". $ _ GET ["hkey"]. ",";
Echo "the value of the hkey parameter is obtained through \ $ _ POST as". $ _ POST ["hkey"]. ",";
Echo "the value of the hkey parameter is obtained through \ $ _ REQUEST as". $ _ REQUEST ["hkey"]. ". \ r \ n ";
Echo "the do value of the parameter is obtained as". $ _ GET ["do"]. ",";
Echo "the do value of the parameter is obtained as". $ _ POST ["do"]. ",";
Echo "the do value of the parameter is obtained through \ $ _ REQUEST as". $ _ REQUEST ["do"]. ". \ r \ n ";
?>


Processing result output:
The value of the parameter name is obtained through $ _ GET. The value of the parameter name is obtained as zkj through $ _ POST, and the value of the parameter name is obtained as zkj through $ _ REQUEST.
The value of parm is obtained as url-post through $ _ GET, the value of parm is obtained through $ _ POST, and the value of parm is obtained as url-post through $ _ REQUEST.
The value of the hkey is obtained through $ _ GET, and the value of the hkey is obtained as hvalue through $ _ POST. The value of the hkey is obtained as hvalue through $ _ REQUEST.
The do value of the parameter is obtained as index through $ _ GET, the do value of the parameter is obtained through $ _ POST, and the do value of the parameter is obtained as index through $ _ REQUEST.
Conclusion:
The GET form value can be obtained through _ GET, but the parameter set through the url parameter of action cannot always be obtained.
The POST form value can be obtained through _ POST, but the parameter set through the action url parameter can be obtained through _ GET
The same variable can be obtained through _ GET, but the variable setting is hidden in the GET form. in the POST form, the variable is set through the url parameter of action.

Why? Because there are two types of form processing: GET and POST, how to pass the do parameter in both forms, in addition, it is always confusing to obtain data in the same way in the background...

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.