Jump to content
deserty

Curlopt_postfields

Recommended Posts

Posted


<?php

$postdata="user=xxx&password=xxx*1&Submit=login";
$curl = curl_init();

curl_setopt ($curl, CURLOPT_URL, "http://www.site/index.php?act=login");
curl_setopt ($curl, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($curl, CURLOPT_POST, 1);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
curl_close ($curl);
echo $result;
?>

Scriptul merge, insa dupa logare as dori sa-mi afiseze o alta pagina din website.

De exemplu http://www.site/pagina.php?id=10

Mc.

Posted (edited)

trebuie sa folosesti si cookie :) vezi ca am postat eu o clasa curl care e mult mai simpla de folosit si face si partea cu cookies pentru tine :)

https://rstcenter.com/forum/56092-php-clasa-curl.rst

edit: nu am fost destul de clar :)

salvezi cookie la primul request si apoi mai faci un request catre pagina care vrei sa o vezi :)

sau daca pagina iti returneaza 301/302 trebuie sa pui CURLOPT_FOLLOWLOCATION true

curl_setopt($curl , CURLOPT_FOLLOWLOCATION , true);

Edited by Xander

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...