Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Wysyłka na URL $_POST
Randallmaster
post
Post #1





Grupa: Zarejestrowani
Postów: 677
Pomógł: 11
Dołączył: 18.11.2009

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


Witam,

Potrzebuje wysłać zmiene w $_POST:

$_POST['name']
$_POST['surname']

na adres: http://docelowyadres.pl/

nie może to być w formularzu<form>.

Próbowałem tak:

$postdata = http_build_query(array('NAME' => $_POST['name'], 'SURNAME' => $_POST['surname']));
$context = stream_context_create($postdata);
fopen('http://docelowyadres.pl/', 'r', false, $context);

niestety wyskakują błędy

Warning: stream_context_create() expects parameter 1 to be array, string given in ...

Warning: fopen() expects parameter 4 to be resource, string given in ...
Go to the top of the page
+Quote Post
pabito
post
Post #2





Grupa: Zarejestrowani
Postów: 77
Pomógł: 4
Dołączył: 14.05.2013

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


a próbowałeś wysłać dane za pomocą CURL ?

  1. <?php
  2. //
  3. // A very simple PHP example that sends a HTTP POST to a remote site
  4. //
  5.  
  6. $ch = curl_init();
  7.  
  8. curl_setopt($ch, CURLOPT_URL,"http://www.mysite.com/tester.phtml");
  9. curl_setopt($ch, CURLOPT_POST, 1);
  10. curl_setopt($ch, CURLOPT_POSTFIELDS,
  11. "postvar1=value1&postvar2=value2&postvar3=value3");
  12.  
  13. curl_exec ($ch);
  14. curl_close ($ch);
  15. ?>


Ten post edytował pabito 6.06.2013, 11:18:49
Go to the top of the page
+Quote Post
Randallmaster
post
Post #3





Grupa: Zarejestrowani
Postów: 677
Pomógł: 11
Dołączył: 18.11.2009

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


Zrobiłem Curl'a tylko potrzebuję aby ta strona mi się jeszcze wyświetliła (IMG:style_emoticons/default/sad.gif)

Myślałem że ta linijka jest odpowiedzialna za otwarcie:
curl_setopt($ch, CURLOPT_URL,"http://www.mysite.com/tester.phtml");
Go to the top of the page
+Quote Post
!*!
post
Post #4





Grupa: Zarejestrowani
Postów: 4 298
Pomógł: 447
Dołączył: 16.11.2006

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


  1. echo curl_exec ($ch);
Go to the top of the page
+Quote Post
Randallmaster
post
Post #5





Grupa: Zarejestrowani
Postów: 677
Pomógł: 11
Dołączył: 18.11.2009

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


Wyświetliło tylko nie pobiera styli (IMG:style_emoticons/default/sad.gif) i sam tekst bez obrazków się wczytał. Jak temu zaradzić?
Go to the top of the page
+Quote Post
!*!
post
Post #6





Grupa: Zarejestrowani
Postów: 4 298
Pomógł: 447
Dołączył: 16.11.2006

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


  1. echo '<base href="domena" />' .curl_exec($curl);
Go to the top of the page
+Quote Post
Randallmaster
post
Post #7





Grupa: Zarejestrowani
Postów: 677
Pomógł: 11
Dołączył: 18.11.2009

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


fajnie działa tylko wyskakują mi błędy w znakach polskich: �
Go to the top of the page
+Quote Post
pabito
post
Post #8





Grupa: Zarejestrowani
Postów: 77
Pomógł: 4
Dołączył: 14.05.2013

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


sprawdź czy Twoja strona i strona do której się odwołujesz ma ustawione kodowanie na utf-8

Ten post edytował pabito 6.06.2013, 14:33:52
Go to the top of the page
+Quote Post
Randallmaster
post
Post #9





Grupa: Zarejestrowani
Postów: 677
Pomógł: 11
Dołączył: 18.11.2009

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


No właśnie w ked mam ustawione utf-8(bez BOM) strona docelowa ma UTF-8 ;/
Go to the top of the page
+Quote Post
pabito
post
Post #10





Grupa: Zarejestrowani
Postów: 77
Pomógł: 4
Dołączył: 14.05.2013

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


Twoja strona powinna mieć utf-8
Go to the top of the page
+Quote Post
Randallmaster
post
Post #11





Grupa: Zarejestrowani
Postów: 677
Pomógł: 11
Dołączył: 18.11.2009

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


w kedzie zmieniłem ale nic to nie dało
Go to the top of the page
+Quote Post
pabito
post
Post #12





Grupa: Zarejestrowani
Postów: 77
Pomógł: 4
Dołączył: 14.05.2013

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


masz ustawiony charset=utf-8 w nagłówku strony ?

spróbuj też tego na danych, które pobierasz

  1. $data=utf8_decode($data)]


Ten post edytował pabito 6.06.2013, 14:50:16
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: 25.12.2025 - 13:49