There are two ways to submit data on PHP pages: get and post. The differences are: 1. When submitting with get, you can see the parameters on the URL address, while when submitting with post, you cannot see the parameters on the address bar; 2. Get is not safe. , post is safe; 3. Get submission is to submit parameters one by one, and post submission is to submit all parameters together as a whole; 4. Get submission generally does not exceed 255 bytes, and the size of post submission depends on the server; 5. Get is very Flexible, parameters can be passed as long as there is a page jump, while post is not flexible.
The operating environment of this tutorial: windows7 system, PHP8 version, DELL G3 computer
In the php page, there are two ways to submit data :get mode and post mode.
<form method="post" action=""></form> <form method="get" action=""></form>
The difference between get method and post method
1. Appearance
get Submit and you can see the parameters in the address
post Submit and you can see the parameters in the address bar
2. Security
get is not safe, post is safe
The data submitted by get can be seen in the url bar, but the data submitted by post is invisible, so post is safer .
3. Submission principle
get submission is to submit parameters one by one
post submission is to submit all parameters together as a whole
4. Submitted data size
Get submission generally does not exceed 255 bytes
The size of post submission depends on the server
// 在php.ini中,可以配置post提交的大小 post_max_size = 8M
5. Flexibility
get is very flexible. You can pass parameters as long as there is a page jump
post is not flexible. Post submission requires the participation of a form
1、 html跳转 <a href="index.php?name=tom&age=20">跳转</a> 2、JS跳转 <script type="text/javascript"> location.href=&#39;index.php?name=tom&age=20&#39;; location.assign(&#39;index.php?name=tom&age=20&#39;); location.replace(&#39;index.php?name=tom&age=20&#39;); </script> 3、PHP跳转 header(&#39;location:index.php?name=tom&age=22&#39;)
Summary:
POST | ||
---|---|---|
You can see the parameters and values passed in the address | No data can be seen in the address bar | |
Submit a small amount of data, different browsers have different maximum values, IE is 255 characters | Submit a large amount of data, you can set it by changing the php.ini configuration file The maximum value of post submission data | |
Low | High | |
The submitted data and the data are independent | Convert the submitted data into XML format for submission | |
Flexible, as long as there is a page jump, you can get and pass data | Inflexible |