-
Comparison form [Url=javascript:;] Post[/url] and Fsockopen submit two different ways of difference.
Form Post Mode submission case
$_post and [url=javascript:;] Php[/url]://input can fetch a value, $HTTP _raw_post_data is empty
$_post organizes the submitted data in an associative array, and encodes it, such as UrlDecode, or even transcoding.
Php://input can get unprocessed post raw data via input stream in file read mode
Php://input allows the raw data to be read from the POST. Compared to $HTTP _raw_post_data, it brings less pressure to memory and does not require any special php.ini settings. Php://input cannot be used for enctype= "Multipart/form-data".
Fsockopen Submit Post Data
Cases:
$sock = Fsockopen ("localhost", $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 (i) results
Conclusion:
1. Php://input can be easily taken to the original post data
2. $HTTP _raw_post_data only the Content-type type in the POST is not PHPOnly valid when recognized
If post data is normally submitted through the page form, it cannot be extracted via $http_raw_post_data. Because of its encoding type attribute (Enctype property) is application/x-www-form-urlencoded, Multipart/form-data.
Note: Even if the Enctype property is explicitly changed within the page to be an unrecognized type for PHP, it is still invalid.
Because the form submission encoding attribute is form-qualified, the unrecognized type is considered to be committed by default encoding (that is, application/x-www-form-urlencoded)
3. $_post is only available when data is submitted by application/x-www-form-urlencoded type.
Plus-.S. HTMLThe search is considered a static page pull.
PHP Fsockopen submit the post data to explain