Compare two different methods of form [url = javascript:;] POST [/url] And fsockopen commit.
When the form POST method is submitted
$ _ POST and [url = javascript:;] php [/url]: // input can get the value, $ HTTP_RAW_POST_DATA is blank
$ _ POST organizes submitted data in an associated array and performs encoding, such as urldecode or even encoding conversion.
Php: // input: Raw POST data that has not been processed can be obtained by reading files from the input stream.
Php: // input allows reading original POST data. Compared with $ HTTP_RAW_POST_DATA, it puts less pressure on the memory and does not require any special php. ini settings. Php: // input cannot be used for enctype = "multipart/form-data ".
Fsockopen submits POST Data
Example:
$ Sock = fsockopen ("localhost", 80, $ errno, $ errstr, 30 );
If (! $ Sock) die ("$ errstr ($ errno )");
$ Data = "txt =". urlencode ("medium"). "& bar =". urlencode ("Value for Bar ");
Fwrite ($ sock, "POST/posttest/resp ***** e. php HTTP/1.0 ");
Fwrite ($ sock, "Host: localhost ");
Fwrite ($ sock, "Content-type: application/x-www-form-urlencoded ");
Fwrite ($ sock, "Content-length:". strlen ($ data )."");
Fwrite ($ sock, "Accept :*/*");
Fwrite ($ sock ,"");
Fwrite ($ sock, "$ data ");
Fwrite ($ sock ,"");
$ Headers = "";
While ($ str = trim (fgets ($ sock, 4096 )))
$ Headers. = "$ str ";
Echo "";
$ Body = "";
While (! Feof ($ sock ))
$ Body. = fgets ($ sock, 4096 );
Fclose ($ sock );
Echo $ body;
Consistent with (1) Results
Conclusion:
1. You can use php: // input to conveniently retrieve the original POST data.
2. $ HTTP_RAW_POST_DATA is valid only when the POST Content-Type is not recognized by PHP.
For example, the POST data submitted through the page form cannot be extracted through $ HTTP_RAW_POST_DATA. The encoding type attribute (enctype attribute) is application/x-www-form-urlencoded and multipart/form-data.
Note: even if the enctype attribute is explicitly changed to an unrecognized PHP type on the page, it still does not work.
Because the form submission encoding attribute is a form limitation, unrecognized types are considered to be submitted in the default encoding mode (application/x-www-form-urlencoded)
3. $ _ POST is only available when data is submitted by application/x-www-form-urlencoded type.
With -.shtml, search is regarded as static page pulling.