为什么我不能通过php的curl提交表单?

时间:2010-05-10 06:59:37

标签: php forms

 $ua_s = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14';
 $c = curl_init($the_url);
 curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt($c, CURLOPT_USERAGENT, $ua_s); 
 curl_setopt($c, CURLOPT_POST, true);
 curl_setopt($c, CURLOPT_POSTFIELDS, $post_string);
 $cont = curl_exec($c);
 curl_close($c);

发送所有必填字段但未能正确提交。编写了html表单进行测试 - 如果在浏览器中完成,那么一切都很好:

2 个答案:

答案 0 :(得分:2)

目标脚本可能需要存在某个cookie,或者引荐来源与脚本位于同一个域中。

答案 1 :(得分:0)

你的$ post_string是怎样的?它是urlencoded吗?