Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [cURL] Przesyłanie danych metodą POST.
carck3r
post
Post #1





Grupa: Zarejestrowani
Postów: 40
Pomógł: 2
Dołączył: 9.11.2008

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


Witam
Mam dwa pliki:
1. index.php, w którym jest taki kod:
  1. <?php
  2.  
  3. $curl = curl_init();
  4.  
  5.     curl_setopt($curl, CURLOPT_URL, 'http://localhost/posttest.php');
  6.     curl_setopt($curl, CURLOPT_POST, 1);
  7.     curl_setopt($curl, CURLOPT_POSTFIELDS, 'login=carck3r&password=ultratajne');
  8.  
  9. curl_exec($curl);
  10. curl_close($curl);
  11.  
  12. ?>

2. posttest.php, w którym mam taki kod:
  1. <?php
  2.  
  3. print_r($_POST);
  4.  
  5. ?>


Po uruchomieniu pliku http://localhost/posttest.php ukazuje się coś takiego:
Kod
Array ( )


A powinno:
Kod
Array (     [login] => carck3r     [password] => ultratajne )
I to pojawia się w index.php, a powinno w posttest.php. Dlaczego tak się dzieje? Jaki popełniłem błąd?
Z góry dzięki za odpowiedzi.

Ten post edytował carck3r 3.01.2009, 18:37:42
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
carck3r
post
Post #2





Grupa: Zarejestrowani
Postów: 40
Pomógł: 2
Dołączył: 9.11.2008

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


Tak myślałem, ale na stronie:
http://www.hudzilla.org/php/15_10_4.php
NIC takiego nie ma.
Cytat
Note that CURLOPT_RETURNTRANSFER was used but the output from curl_exec() was ignored - this is because the extra data provided by CURLOPT_VERBOSE is actually sent straight to the browser irrespective of CURLOPT_RETURNTRANSFER, so by ignoring the output of curl_exec() the script will only print out the debugging information.
Go to the top of the page
+Quote Post

Posty w temacie


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: 10.10.2025 - 16:58