Long time useless fsockopen, incredibly forgot the format of the post. Fsockopen Post form 2006-04-27 14:42:05 bailing
It is important to note that 1.form data must be rawurlencode encoded together. 2. Data that must be submitted for Content-length length 3.post form must be followed by \r\n\r\n. $data ["Channel"]= $moRow [' Servicecode ']; $data ["Mobile"]= $moRow [' Mobile ']; $data ["Gateway"]= $moRow [' Gateway '];$ data["ISP"]= $moRow [' ISP ']; $data ["LinkId"]= $moRow [' LinkId ']; $data ["msg"]= $content; while (List ($k, $v) = each ($data) {$post. = Rawurlencode ($k). " = ". Rawurlencode ($v)." & ";} $post = substr ($post, 0,-1); $len = strlen ($post);//Send $host = "localhost"; $file = "/mtapp/send.php"; $fp = @fsockopen ( $host, $errno, $errstr), if (! $fp) {echo "$errstr ($errno) \ n";} else {$receive = '; $out = "POST $file http/1.1\r\n"; $out. = "Host: $host \ r \ n"; $out. = "content-type:application/x-www-form-urlencoded\r\n"; $out. = "connection:close\r\n"; $out. = "Content-length: $len \ r \ n"; $out. = "\ r \ n"; $out. = $post. " \ r \ n "; echot ($out); Fwrite ($fp, $out); while (!feof ($fp)) {$receive. = fgets ($fp, 128); } fclose ($FP);} echo $receive; A common post-head post/cgi-bin/tech/method.cgi HTTP/1.1ACCEpt:image/gif, Image/x-xbitmap, Image/jpeg, Image/pjpeg, Application/vnd.ms-powerpoint, Application/vnd.ms-excel, Application/msword, */*referer:http://localhost//other.htmlaccept-language:zh-cncontent-type:application/ X-www-form-urlencodedaccept-encoding:gzip, deflateuser-agent:mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) host:localhost:8080content-length:9connection:keep-alive