Hello I am trying to login to the website bellow to get some data from there, I am trying to do this with cURL, I have tried multiple settings and mostly what I found here on this website, this is as closest as I have got. Because this code is the only one that so far can create the cookie file(it does not write anything in the cookie file but creates a file like coo8361.tmp each time the last 4 digits are random). I tried this on a simple form that I made and it's working just fine, it inserts some data into MySQL.
If you can give me any notes or information that I may use it would be very helpful.
Thank you
$username = '23434';
$password = 'sdfsfdsdf';
$ckfile = tempnam ("./", "cookie.txt");
$target_host = "http://www.somewebsite.com";
$target_request = "logon.html?ut=4";
$post_data = "action=LogonForm&username=$username&ownerPassword=$password";
$ch = curl_init ($target_host);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
// 3. Continue
$login = curl_init ($target_host.$target_request);
curl_setopt($login, CURLOPT_COOKIESESSION, 1);
curl_setopt($login, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($login, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($login, CURLOPT_TIMEOUT, 40);
curl_setopt($login, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($login, CURLOPT_HEADER, 1);
curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($login, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($login, CURLOPT_POST, 1);
curl_setopt($login, CURLOPT_POSTFIELDS, $post_data);
echo curl_exec($login);
curl_close($login);