Mam następujący kod:
Kod
$post_data = array();
$post_data['login_str'] = "xxx";
$post_data['password_str'] = "xxxxxx";
$post_data['m'] = "";
$post_data['g'] = "";
$post_data['URI'] = "admin.php";
$post_data['check'] = 1;
$url = "http://xxx.pl/users/login.php";
$o="";
foreach ($post_data as $k=>$v)
{
$o.= "$k=".utf8_encode($v)."&";
}
$post_data=substr($o,0,-1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result = curl_exec($ch);
unset($post_data);
$post_data = array();
$post_data['u'] = "";
$post_data['check'] = "Dodaj";
$post_data['Q[2216]'] = "cos";
$post_data['Q[2223]'] = "tes";
$post_data['Q[2262]'] = "lublin :)";
$post_data['Q[2214]'] = 4;
$post_data['id_advert'] = 0;
$post_data['id_category'] = |14|2|;
$url = "http://xxx.pl/manage/add.php";
$o="";
foreach ($post_data as $k=>$v)
{
$o.= "$k=".utf8_encode($v)."&";
}
$post_data=substr($o,0,-1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result = curl_exec($ch);
echo $result;
"Pierwszy" curl dotyczy logowania - powinien zalgowac do systemu, a drugi powinien dodac zdarzenie lecz ani to ani tamto nie ma miejsca (oczywiscie nie dodaje sie zdarzneie bo user niezalogowany).
Nigdy nie uzywalem curla wiec jakby, ktos moglby pomoc mi w rozwiazaniu tego problemu to bylbym wdzieczny.
Pozdroawiam Pawel