drzrdc1766788 2012-07-28 17:12
浏览 37
已采纳

PHP post数组和curl提交

I have built a form submission consisting of about 90 values. The form needs to be submitted to another page that has a curl session which handles the last part. My question is, when I submit that form, how do I access the $_Post[] data as a whole array so I can submit it as the curl post array?

need to get

<form name="send" action="process.php" method="post">
<input 1>
<inpit 2>
...
<input 90>
</form>

to

process.php :

curl_setopt( $ch, CURLOPT_POSTFIELDS, $_Post[] );

Or is it as easy as putting $Post[]?

  • 写回答

1条回答 默认 最新

  • douyong5476 2012-07-28 17:23
    关注

    From the manual, the CURLOPT_POSTFIELDS value can be in a query-string format, var1=value1&var2=value2... or in an array format with the key being the field name, such as you have with $_POST.

    You are currently using $_POST[] in your example; drop the [] and it should work fine:

    curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部