向服务器提交POST表单并保存结果的原理,可做刷票系统。

         $str = " username=test&password=123 "
        
$fp = fsockopen ( " www.123cha.com " , 80 );
        
fputs ( $fp , " POST /postal/index.php HTTP/1.1 " );
        
fputs ( $fp , " Host:www.123cha.com " );
        
fputs ( $fp , " Content-Type:application/x-www-form-urlencoded " );
        
fputs ( $fp , " Content-Length: " . strlen ( $str ) . " " );
        
fputs ( $fp , $str . " " );
        
while ( ! feof ( $fp ))
        {
                
$http_response .= fgets ( $fp , 128 );
        }
        
fclose ( $fp );
 

你可能感兴趣的:(12-PHP编程,服务器,fp)