I have a script with collects a unique id. I then want to pass this id between 5 or 6 forms. How do I do this?
The first script looks like this:
<?php
$sHTMLpage = "https://www.aquote.co.uk/motor/ipl/ipl.dll?run+aquotepc:ipl/pagecontrol";
$htmlPage = getUrlViaHTTPS($sHTMLpage);
if (preg_match('/<form method="POST" action="\/motor\/ipl\/ipl\\.dll\\?go\\+([0-9]*)/', $htmlPage, $store)) {
$id = $store[1];
echo "ID Found: " . $id;
} else {
$id = "";
echo "No ID found";
}
function getUrlViaHTTPS($sURL) {
$cURLHandle = curl_init();
curl_setopt($cURLHandle, CURLOPT_URL, $sURL);
curl_setopt($cURLHandle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cURLHandle, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($cURLHandle, CURLOPT_SSL_VERIFYHOST, 2);
$returnValue = curl_exec($cURLHandle);
if (curl_errno($cURLHandle)) {
return curl_errno($cURLHandle) . ' - ' . curl_error($cURLHandle);
} else {
return $returnValue;
}
curl_close($cURLHandle);
}
$ch = curl_init("https://www.aquote.co.uk/motor/ipl/ipl.dll?go+".$id."+0");
$fp = fopen("test1.txt", "w");
$POSTFIELDS = " ";
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
I then have 6 more forms to process using this code with different $POSTFIELDS variables. All of which will require $id.
<?php
$ch = curl_init("https://www.aquote.co.uk/motor/ipl/ipl.dll?go+".$id."+1");
$fp = fopen("test3.txt", "w");
$POSTFIELDS = "ContactTitle=Mr&ContactForenames=Neil&ContactSurname=Munn&ContactEmail=neil@shsuyeem.com&ContactDayTel=01536521393&ContactEveTel=01536521393&ContactHouseNo=27&ContactPostcode=NN155BZ&PolicyIncepDate=251105";
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
How do I pass $id between these forms? And would it be possible to automate the sending of the forms?
Thanks,
Neil