Reputation: 1046
I am trying to link our page to another, but it is on the other side of a disclaimer warning. Before everyone gets on my case for trying to do something unethical, I am merely trying to make the link easy for my user to get to a page - I am NOT scraping any information or otherwise doing something shady!
The link I am having issues with is this:
https://www.bcpao.us/asp/disclaimap.asp
I am trying to press this button:
<input type="submit" name="Answer" value="Accept"\>
Here is my php/curl code:
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$url = 'https://www.bcpao.us/asp/disclaimap.asp';
$ckfile = tempnam ("d:/temp", "CURLCOOKIE");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data['Answer'] = "Accept";
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// I have tried the following also:
// curl_setopt($ch, CURLOPT_POSTFIELDS, "Submit=Answer%Accept");
$output=@curl_exec($ch);
$info = @curl_getinfo($ch);
if(curl_errno($ch)){
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
echo "output is:'" . $output . "'";
echo "<br>";
echo "info is:";
print_r($info);
When I run the script, I get the original page back (not the one the button links to.) Any help would be most appreciated!
Upvotes: 3
Views: 18848
Reputation: 3549
Take a look at the form
tag:
<form action="answer_disclaimap.asp" method="post" id="Form1">
You use wrong URL
to disclaimap.asp
. Change it to answer_disclaimap.asp
:
$url = 'https://www.bcpao.us/asp/answer_disclaimap.asp';
And use http_build_query():
$data['Answer'] = "Accept";
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($data) );
Upvotes: 3