最近...不多說,說多了都是淚,直接上問題和答案:
//假設host:localhost
//Client.php文件內容爲:
$url = "http://localhost/server.php";
$fp = fsockopen ( "localhost", 80, $errno, $errstr, 3 );
$head = "POST /server.php HTTP/1.0\r\n";
$head .= "Accept: image/jpeg, image/gif, image/pjpeg, */*\r\n";
$head .= "User-Agent: Mozilla/4.0\r\n";
$head .= "Content-type: application/x-www-form-urlencoded\r\n";
$head .= "Host: localhost\r\n";
$head .= "Content-Length: 34\r\n";
$head .= "Connection: Keep-Alive\r\n";
$head .= "Cookie: HOSUPPORT=1; UBI=fi_Pnc;\r\n";
$head .= "\r\n";
$head .= trim ( "username=a&password=c&action=login" );
$write = fputs ( $fp, $head );
fgets ( $fp );
while ( ! feof ( $fp ) ) {
$line = fgets ( $fp );
echo $line . "<br>";
}
//Server.php內容爲:
echo md5($_POST['username'].$_POST['password']);