易截截图软件、单文件、免安装、纯绿色、仅160KB

php 通过fsockopen 模拟POST提交


$URL
=‘
http
:
//xxx.xxx.xxx.xx/xx/xxx/top.php';
$post_data
[
'
clientname
'
]
=
"
test08
"
;
$post_data
[
'
clientpasswd
'
]
=
"
test08
"
;
$post_data
[
'
submit
'
]
=
"
ログイン
"
;
$referrer
=
""
;
// parsing the given URL
$URL_Info
=
parse_url
(
$URL
)
;
// Building referrer
if
(
$referrer
==
""
)

// if not given use this script as referrer
$referrer
=
$_SERVER
[
"
SCRIPT_URI
"
]
;
 
// making string from $data
foreach
(
$post_data

as

$key
=>
$value
)
$values
[]
=
"
$key
=
"
.
urlencode
(
$value
)
;
 
$data_string
=
implode
(
"
&
"
,
$values
)
;
// Find out which port is needed - if not given use standard (=80)
if
(
!
isset
(
$URL_Info
[
"
port
"
]))
$URL_Info
[
"
port
"
]
=
80
;
// building POST-request:
$request
.=
"
POST
"
.
$URL_Info
[
"
path
"
]
.
"
HTTP/1.1
\n
"
;
$request
.=
"
Host:
"
.
$URL_Info
[
"
host
"
]
.
"
\n
"
;
$request
.=
"
Referer:
$referrer
\n
"
;
$request
.=
"
Content-type: application/x-www-form-urlencoded
\n
"
;
$request
.=
"
Content-length:
"
.
strlen
(
$data_string
)
.
"
\n
"
;
$request
.=
"
Connection: close
\n
"
;
$request
.=
"
\n
"
;
$request
.=
$data_string
.
"
\n
"
;
$fp
=
fsockopen
(
$URL_Info
[
"
host
"
]
,
$URL_Info
[
"
port
"
])
;
fputs
(
$fp
,
$request
)
;
while
(
!
feof
(
$fp
))

{
    
$result
.=
fgets
(
$fp
,
128
)
;
}
fclose
(
$fp
)
;


相关文档:

PHP向特定URL发送POST数据

今天工作中遇到了POST数据的问题,需要向一个特定的URL发送POST数据。
现将PHP发送POST数据的方式总结下,方便自己造福后人:
方法一:HTTP函数发送方式
说明:$data为POST发送的数据:$key为参数名,$val为参数值
$URL = "http://pre.payment.sdoa.sdo.com/";
$data = $key1."=".val1."&".$key2."=".val2;
$Post ......

php的static变量作用域

对于运行在apache里的php应用来说,static变量的作用域是一次http请求。
可以通过以下代码进行验证:
<?php
# test.php
function test(){
     static $sss = 0;
     ++$sss;
     echo $sss;
}
test();
?>
访问/test.php ,可以看到,总是 ......

php打开错误提示

如果不具备修改php.ini的权限,可以如下:
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
当然,如果能够修改php.ini的话,如下即可:
display_errors = On
error_reporting  =  E_ALL & ~E_NOTICE ......

PHP创建excel文件简单的方法

<?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=php100.xls");

/* echo "A1\t B1\t C1\n";
echo "A1\t B1\t C1\n";
echo "A1\t B1\t C1\n";
*/
?>
<!--*********************************************报表***************************************** ......

PHP开发人员应熟悉的五个概念

语法结构教科书上的知识和实际的程序设计是有区别的,真正的知识要在实际的开发中获得。每个php的开发人员在开始开发web应用程序之前,都应该熟悉下面的五件事: www.phperz.com

1. 框架

php程序员之家
框架可以说是php开发中的一个最重要的问题。用php开发web应用程序时有很多方法,有很多开源的框架可以使用,可 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号