I'm trying to submit a FORM using POST to a https site (only POST, GET is not allowed).
1. The site requires you to send required fields (theoretically using a FORM) to PAGE A. This POST creates a Java Servlet session id on PAGE A. No cookies are set on the browser that I know of.
2. Once part 1 is done, PAGE A has another FORM where you fill in more details and click on submit which submits the FORM to PAGE B. This submission finalizes the process.
I'm wondering if the whole process can be done with cURL. I tried sending parts 1 and 2 all at the same time with POST, but it doesn't work.
Can this be done ?
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL, "https://thesite.com/folder/PAGE A"); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // times out after 10s
curl_setopt($ch, CURLOPT_POST, true); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, "iputthepostfieldshere"); // add POST fields
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1)");
$result = curl_exec($ch); // run the whole process
curl_close($ch);