tags:

views:

32

answers:

2
 $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);

send all needed fields but fail to submit it properly. wrote html form to test - all is well if done so in browser:

+2  A: 

The target script might require a certain cookie to be present or the referrer to be within the same domain as the script.

ThiefMaster
A: 

How does your $post_string looks like? Is it urlencoded?

Piotr Pankowski
Using an array instead of an urlencoded string would be better. Then curl is responsible for encoding it into a string.
ThiefMaster
It depends. If string is used then content is being send as 'application/x-www-form-urlencoded', while using array creates 'multipart/form-data' content. In most cases it doesn't matter but there are servers that can't handle multipart/form-data properly. Also x-www-form-urlencoded is default for POST (unless you are transferring files).
Piotr Pankowski