curl脚本只是填写表单而不是提交它

时间:2012-08-19 18:23:16

标签: php curl

我在PHP cURL中编写了一个脚本来填写表单。 但奇怪的是,表格只是填满而且没有提交表格

这是代码 请帮忙

$cookies = 'C:\wamp\www\costie\cookies.txt';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url1); // set url to post to 
curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable 
curl_setopt($ch, CURLOPT_TIMEOUT, 0); // times out after Ns 
curl_setopt($ch, CURLOPT_POST, 1); // set POST method 
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);

curl_setopt($ch, CURLOPT_POSTFIELDS, "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=$value1&__PREVIOUSPAGE=$value2&__EVENTVALIDATION=$value3&$name1=2008&$name2=02-33-255-009&$name3=&$name4=&$name5=");//ADD post fields

curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
curl_setopt($ch, CURLOPT_VERBOSE, 1); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_COOKIEFILE, 1);  
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);
$result = curl_exec($ch); // run the whole process 
curl_close($ch); 
echo $result;

0 个答案:

没有答案