3

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!

1 Answer 1

3

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) );
Sign up to request clarification or add additional context in comments.

1 Comment

Well, your fix worked perfectly, but I didn't get what I expected. Once you have accepted their terms, whenever you browse their site (as a normal user), the URL has an ID="some number" in it. This number persists for a while, but eventually times out (kind of like a cookie) so I was assuming that this number would wind up in the cookie file, but it doesn't... Any suggestions?... Nevermind - after looking at the return page's source html, I found it buried - ounce again, thanks for catching my earlier mistakes :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.