PHP Tutorials $ _post function and $_get function
1, get is from the server to data, post is to send data to the server;
2. Get adds the data in the form, in the form of Variable=value, to the URL that the action points to, and uses the "?" Connection, and the "&" connection is used between the variables. Post is where the data in the form is placed in the form's data body, and is passed to the url;fashion jewelry that the action points to, according to the variable and the value wholesale
So there are two other conclusions to be drawn from the above:
1. The amount of data being transmitted is smaller than 2KB, which is mainly due to the length of the URL. Post transfers have a large amount of data, so you can only use post for uploading files. Generally, the default is unrestricted. Theoretically, the maximum of IIS4 is 100kb in 80KB,IIS5.
2, get security is very low (because the user can see through the URL), post security is high (all of its operations are not visible to the user). But the execution efficiency is better than the Post method;
3. The value of the data set of the Get restriction form form must be an ASCII character, while the post supports the entire iso10646 character set; cleaning cloth
4, get is the default method of form;
5. The data submitted by get method is obtained by using request.querystring () in the server side, and the data submitted by post method is Request.Form (not very clear).
Recommendations:
1, if it contains confidential information, it is recommended to use the Post data submission method;
2, in doing the data query, it is recommended to use get way, while doing data add, modify or delete, the proposed post method;
Get instance
The built-in $ _get function is used to collect values that send a method= "get" from the form. The information is sent in the form of a GET method. The user is visible (it will appear in the browser's address bar) and has limited the amount of information sent.
For example:
<form action= "test.php" method= "Get" >
Name: <input type= "text" name= "username"/>
Age: <input type= "text" name= "age"/>
<input type= "Submit" value= "Submit"/>
</form>
When the user clicks the "Submit" button, the URL sent to the server may look like this:
http://localhost/demo/test.php?username=lily&age=28
In the "test.php" file, you can now use the $ _get function to collect form data (the name of the form field will automatically be the key of the $ _get array):
Welcome <?php echo $_get["username"]; ><br/>
are <?php echo $_get["age";?> Perton old!
When do you use method= "get"?
When using method= "get" in an HTML form, all the variable names and values are displayed in the URL. Note: This method should not be used in passwords or other sensitive information! However, because the variable is displayed in the URL, it is possible to bookmark the page. This can be useful in some cases. The Get method is not suitable for very large variable values. It should not use a value of more than 2000 characters
$_post instance
Built in $ _post feature is used to collect values in a form method= "post". The information sent in the form of the Post method is invisible to the user and has no limit on the amount of information sent. However, there is a 8 MB max size for the Post method, which by default (can be changed by setting the post_max_size in the php.ini file).
For example:
<form action= "welcome.php" method= "POST" >
Name: <input type= "text" name= "username"/>
Age: <input type= "text" name= "age"/>
<input type= "Submit" value= "Submit"/>
</form>
When the user clicks the "Submit" button, the URL sent to the server may look like this:
http://localhost/demo/test.php
In the "test.php" file, you can now use the $ _post feature to collect form data (the form field name will automatically be in the $ _post array key):
Welcome <?php echo $_post["username"]; >!<br/>
You are <?php echo $_post[' age ';?> perton old.
When do I use method= "post"?
The information sent in the form of the Post method is invisible to the user and has no limit on the amount of information sent. However, because the variable is not displayed in the URL, it is impossible to bookmark the page.
PHP's $ _request function
PHP's built-in functions are contained in $ _request in two forms $ _get,$ _post and $ _ Cookies. The $ _request function, which can be used to collect the get and post methods to send form data.
Welcome <?php Echo $_request["username"];? >!<br/>
You are <?php echo $_request[' age ';?> Perton old.