enter image description hereTrying to make a double curl in the first curl we are accepting the message by posting the form to the same page. After that we should be posting another curl with the cookies but for some reason the page is not remembering the old CURL.
I have tried 2 different methods and both don't seem to be working and doing the thing I want them to do. Can someone please tell me how I can get the first CURL page to post to the second one without going back to the message part.
The code is as following:
<?php
// Retrieving session ID
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
// create both cURL resources
$ch1 = curl_init();
$fields = array( 'akkoord'=>'Verder', 'accept'=>'true');
$fields2 = array('akkoord'=>'Verder', 'accept'=>'true', ''=>'Watermolen 21 Edam');
$postvars = '';
foreach($fields as $key=>$value) {
$postvars .= $key . "=" . $value . "&";
}
$postvars2 = '';
foreach($fields2 as $key2=>$value2) {
$postvars2 .= $key2 . "=" . $value2 . "&";
}
// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "https://www.wozwaardeloket.nl/index.jsp");
curl_setopt($ch1, CURLOPT_COOKIEJAR, '/cookies.txt');
curl_setopt($ch1, CURLOPT_COOKIEFILE, '/cookies.txt');
curl_setopt($ch1, CURLOPT_COOKIE, $strCookie );
curl_setopt($ch1, CURLOPT_POSTFIELDS, $postvars);
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, "https://www.wozwaardeloket.nl/index.jsp");
curl_setopt($ch2, CURLOPT_COOKIEJAR, '/cookies.txt');
curl_setopt($ch2, CURLOPT_COOKIEFILE, '/cookies.txt');
curl_setopt( $ch2, CURLOPT_COOKIE, $strCookie );
curl_setopt($ch2, CURLOPT_POSTFIELDS, $postvars2);
//create the multiple cURL handle
$mh = curl_multi_init();
//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
$active = null;
//execute the handles
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);
?>
Thanks in advance!