Ho dimenticato di chiamare la funzione:
codice:
$result = curl_exec($ch);
Che andrebbe sopra a
Ecco il codice completo:
codice:
$agent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.10) Gecko/20100504 Firefox/3.5.10";
$url='http://localhost/login.php';
$reffer='http://localhost/';
$POSTFIELDS="username=".$user."password:".$psw."rememberme=true";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //host
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $header_array);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$POSTFIELDS); //data che incollo
curl_setopt($ch, CURLOPT_REFERER, $reffer); //refer
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //richiesto dal tutorial
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec($ch);
curl_close($ch); // chiudo la connessione
echo $result;
Scusatemi ancora!