Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]metoda post wysyłanie w CURL'u
kubek15
post
Post #1





Grupa: Zarejestrowani
Postów: 278
Pomógł: 3
Dołączył: 28.06.2008
Skąd: PL

Ostrzeżenie: (0%)
-----


Witam. Chce aby dane były wysłane metodą post w CURL'u znalazłem cos takiego ale nie działa mi to niewiem czemu.
  1. <?php
  2. $c = curl_init();
  3. curl_setopt($c, CURLOPT_URL,  "http://www.webcron.pl/index.html\");
  4. curl_setopt($c, CURL_POST, 1);
  5. curl_setopt($c, CURLOPT_POSTFIELDS,  "username=kubek&password=kubek&#092;");
  6. curl_exec($c);
  7. curl_close($c);
  8.  
  9.  
  10. $x = curl_init();
  11. curl_setopt($x, CURLOPT_URL, "http://www.webcron.pl/konto.html\");
  12. curl_setopt($x, CURL_POST, 1);
  13. curl_setopt($x, CURLOPT_POSTFIELDS,  "add_points=true&#092;");
  14. curl_exec($x);
  15. curl_close($x);
  16. ?>

To jest piwerszy formularz.
  1. <form action=index.html method=POST name=login>
  2. <input type=hidden name=login_send value=true>
  3. <table width=100%>
  4. <td align=right><table><tr>
  5. <td>Login:</td>
  6. <td><input type=text class=pole_login name=username size=10></td>
  7. <td>Hasło:</td>
  8. <td><input type=password class=pole_login name=password size=10></td>
  9. <td><input type=submit class=pole_login value="Zaloguj"></td>
  10. </tr></table>
  11. </td></tr></table></form>


Ten post edytował kubek15 12.04.2009, 10:55:25
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
dk1342
post
Post #2





Grupa: Zarejestrowani
Postów: 275
Pomógł: 9
Dołączył: 24.07.2008
Skąd: Racibórz

Ostrzeżenie: (10%)
X----


jak się zaloguje to potem traci sesje zobacz ten temat:

http://forum.php.pl/index.php?showtopic=11...mp;#entry593477

a dokładniej:
  1. <?php
  2. $coockie = "byle_co";
  3. curl_setopt($c, CURLOPT_COOKIEFILE, $cookie);
  4. curl_setopt($c, CURLOPT_COOKIEJAR, $cookie);
  5. ?>
Go to the top of the page
+Quote Post
kubek15
post
Post #3





Grupa: Zarejestrowani
Postów: 278
Pomógł: 3
Dołączył: 28.06.2008
Skąd: PL

Ostrzeżenie: (0%)
-----


a teraz mam tak i dalej nie działa. Pierwsza funkcja ma się zalogować a druga ma wcisnąć przycisk i to nie działa dlaczego? zmienne ma zdefiniowane.
  1. <?php
  2. function _login($site, $login, $pass, $cookie)
  3.   {
  4.       $curl = curl_init();
  5.       curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie);
  6.       curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie);
  7.       curl_setopt($curl, CURLOPT_URL, $site );
  8.       curl_setopt($curl, CURLOPT_POST, 1);
  9.       curl_setopt($curl, CURLOPT_POSTFIELDS, 'username=' . $login . '&password=' . $pass . ' ');
  10.       curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  11.       $result = curl_exec($curl);
  12.       curl_close($curl);
  13.  
  14.       return $result;
  15.   }
  16.  
  17. function _login2($login, $pass, $cookie)
  18.   {
  19.       $curl = curl_init();
  20.       curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie);
  21.       curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie);
  22.       curl_setopt($curl, CURLOPT_URL, "http://www.webcron.pl/konto.html" );
  23.       curl_setopt($curl, CURLOPT_POST, 1);
  24.       curl_setopt($curl, CURLOPT_POSTFIELDS, 'add_points=true');
  25.       curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  26.       $result2 = curl_exec($curl);
  27.       curl_close($curl);
  28.  
  29.       return $result2;
  30.   }
  31. ?>
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 12:27