All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
关于PHP动态网页session问题的解决方案_[PHP教程]
PEAR简介-用PEAR来写你的下一个php程序_[PHP教程]
6种常用ASP.NET验证控件_[Asp.Net教程]
判断远程图片是否存在_[XML教程]
下载:Visual,Studio,2008,Beta,2_[Asp.Net教程]
asp.net2.0访问母版页的控件和属性
delphi类中方法的使用技巧和实例
TABLE导入到EXCEL_[Asp.Net教程]
技巧:PHP+MYSQL动态网页编程纠错指南_[PHP教程]
delphi单选框组件(TRadioButton)使用实例
Reading number is top 10 pictures
粉红蕾丝的美女
含苞欲放的素颜美少女1
Sora aoi possession of boudoir2
From China fortress sora aoi3
英雄联盟超神十连杀截图
China telecom 114 spokesman MeiYanXu1
Kim jong il's mistress, national beauty JinYuJi actor2
Group of female porn in 《westwards》, uninhibited woman threatened to not the bottom line1
清扫五脏垃圾,我有绝招
一千块钱如何创业
Download software ranking
Unix video tutorial11
软件工程思想
双旗镇刀客A
Detective task-the top secret prostitution files
传奇私服架设教程
Red cliff
Macromedia Dreamweaver 8
SP3 for SQL2000
终极变速大师Speeder3.26
C++教程第四版
归海一刀 published in(发表于) 2014/2/10 6:52:53 Edit(编辑)
如何从一个php文件向另一个地址post数据,不用表单和隐藏的变量_[PHP教程]

如何从一个php文件向另一个地址post数据,不用表单和隐藏的变量_[PHP教程]

如何从一个php文件向另一个地址post数据,不用表单和隐藏的变量_[PHP教程]



可以使用以下函数来实现:


function posttohost(url, data) {
url = parse_url(url);
if (!url) return "couldn't parse url";
if (!isset(url['port'])) { url['port'] = ""; }
if (!isset(url['query'])) { url['query'] = ""; }


encoded = "";


while (list(k,v) = each(data)) {
encoded .= (encoded ? "&" : "");
encoded .= rawurlencode(k)."=".rawurlencode(v);
}


fp = fsockopen(url['host'], url['port'] ? url['port'] : 80);
if (!fp) return "Failed to open socket to url[host]";


fputs(fp, sprintf("POST %s%s%s HTTP/1.0\n", url['path'], url['query'] ? "?" : "", url['query']));
fputs(fp, "Host: url[host]\n");
fputs(fp, "Content-type: application/x-www-form-urlencoded\n");
fputs(fp, "Content-length: " . strlen(encoded) . "\n");
fputs(fp, "Connection: close\n\n");


fputs(fp, "encoded\n");


line = fgets(fp,1024);
if (!eregi("^HTTP/1\.. 200", line)) return;


results = ""; inheader = 1;
while(!feof(fp)) {
line = fgets(fp,1024);
if (inheader && (line == "\n" || line == "\r\n")) {
inheader = 0;
}
elseif (!inheader) {
results .= line;
}
}
fclose(fp);


return results;
}
?>
--------------------------------------------------------------------------------------------------
也可以这样


URL="www.mysite.com/test.php";
ch = curl_init();
curl_setopt(ch, CURLOPT_URL,"https://URL");
curl_setopt(ch, CURLOPT_POST, 1);
curl_setopt(ch, CURLOPT_POSTFIELDS, "Data1=blah&Data2=blah");
curl_exec (ch);
curl_close (ch);
?>


作者:铁鹰 来源:CSDN







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.