使用php模拟post提交数据
来源:互联网 发布:java趣味编程100例ppt 编辑:程序博客网 时间:2024/04/28 00:36
- <?php
- $target = "http://www.xxxx.com/xxxx.php";
- $host = "www.xxxx.com";
- $msg = "id=1&pw=1";
- $httpheader = "POST ".$target." HTTP/1.1/r/n";
- $httpheader .= "Accept:*/*/r/n";
- $httpheader .= "Accept-Language:zh-cn/r/n";
- $httpheader .= "Referer:".$target."/r/n";
- $httpheader .= "Content-Type:application/x-www-form-urlencoded/r/n";
- $httpheader .= "User-Agent:Mozilla/4.0(compatible;MSIE 7.0;Windows NT 5.1)/r/n";
- $httpheader .= "Host:".$host."/r/n";
- $httpheader .= "Content-Length:".strlen($msg)."/r/n";
- $httpheader .= "Connection:Keep-Alive/r/n";
- $httpheader .= "/r/n";
- $httpheader .= $msg;
- $fd = fsockopen($host,80);
- fwrite($fd,$httpheader);
- $gets = "";
- while(!feof($fd)){
- $gets .= fread($fd,8192);
- }
- fclose($fd);
- echo "ok";
- echo $gets;
- ?>