I've been trying to submit below form using PHP curl but it gives me no access, when I just open the HTML file with below code and press submit, it works!
<form action="http://www.example.com/47595ADEDFGVB558S" method="post">
<input type="submit" name="warning" value="Yes, let me in">
</form>
Here is my PHP block
$url = 'http://www.example.com/47595ADEDFGVB558S';
$data = array('warning' => 'Yes, let me in' );
$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, http_build_query($data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$returndata = curl_exec($ch);
curl_close($ch);
echo $returndata ;
Headers when submitted via browser
Request Method:POST
Status Code:302 Moved Temporarily
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,fr;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:25
Content-Type:application/x-www-form-urlencoded
Host:www.example.com
Origin:http://www.example.com
Referer:http://www.example.com/47595ADEDFGVB558S
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36
Form Dataview sourceview URL encoded
warning:Yes, let me in
where am I doing wrong? I tried setting origin, host headers but i think error is with the data being submitted.