Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Przekazanie parametru do skryptu za pomocą POST, bez użycia formularzy
bełdzio
post
Post #1





Grupa: Zarejestrowani
Postów: 690
Pomógł: 81
Dołączył: 6.04.2005
Skąd: Szczecin

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


Witam, chciałem się dowiedzieć czy jest możliwość przekazania do skryptu parametru post`em bez użycia formularzy ?


--------------------
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 8)
Wave
post
Post #2





Grupa: Zarejestrowani
Postów: 332
Pomógł: 6
Dołączył: 13.01.2005

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


Nie.
Go to the top of the page
+Quote Post
bełdzio
post
Post #3





Grupa: Zarejestrowani
Postów: 690
Pomógł: 81
Dołączył: 6.04.2005
Skąd: Szczecin

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


jak nie jak tak biggrin.gif np.
http://curl.haxx.se/mail/curlphp-2004-05/0026.html
http://www.webmasterworld.com/forum88/5375.htm
http://codewalkers.com/archives/phpcoding/8293.html

ps topik można zamknąć or del bo udało mi się to obejść winksmiley.jpg


--------------------
Go to the top of the page
+Quote Post
Dravo
post
Post #4





Grupa: Zarejestrowani
Postów: 207
Pomógł: 0
Dołączył: 7.09.2003

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


Oczywiście że istnieje.
You can open an HTTP socket connection and send HTTP POST commands. Here is
an example :
Możemy użyć dwóch metod.

1. Tradycyjnie - za pomocą połącznie socketowego i wysłania żądania HTTP POST.

  1. <?
  2. // Nagłówek zapytania
  3. $ReqHeader =
  4. &#092;"POST $URI HTTP/1.1n\".
  5. &#092;"Host: $Hostn\".
  6. &#092;"Content-Type: application/x-www-form-urlencodedn\".
  7. &#092;"Content-Length: $ContentLengthnn\".
  8. &#092;"$ReqBodyn\";
  9.  
  10. // Otwórz połączenie
  11. $socket = fsockopen ( $Host, 80, &$errno, &$errstr );
  12. if ( !$socket )
  13.  
  14. $Result [ &#092;"errno\" ] = $errno;
  15. $Result [ &#092;"errstr\" ] = $errstr;
  16. return $Result;
  17. }
  18. $idx = 0;
  19. fputs( $socket, $ReqHeader );
  20. while ( !feof ( $socket ) )
  21.  
  22. $Result [ $idx++ ] = fgets ( $socket, 128 );
  23. }
  24. //-------------------------------------------
  25. ?>


2. Rozszerzenie cURL
Jest to bajeczny wręcz sposób na osiągniecie twojego celu.

  1. <?
  2. $URL=&#092;"www.mysite.com/test.php\";
  3. $ch = curl_init();  
  4. curl_setopt($ch, CURLOPT_URL,&#092;"https://$URL\");
  5. curl_setopt($ch, CURLOPT_POST, 1);
  6. curl_setopt($ch, CURLOPT_POSTFIELDS, &#092;"Zmienna1=heh&Zmienna2=heh2\");
  7. curl_exec ($ch);
  8. curl_close ($ch);
  9. ?>

Zauważ że nie potrzebujesz określać nagłówków.

Polecam drugi sposób. cURL powinno być wkompilowane w serwer.


--------------------
Oooo, cia is on the phone... Ok, I got it. Shit I lost it.
Go to the top of the page
+Quote Post
-johnyVox-
post
Post #5





Goście







Nie działa mi kod Drava (chodzi o przesyłanie nagłówkami).

Jego kod jest jakichs dziwny i niekompletny.
Widziałem coś na stronie manuala, ale tesh nie działa:
  1. <?php
  2. function HTTP_Post($URL,$data, $referrer=&#092;"\") {
  3.  
  4.  // parsing the given URL
  5.  $URL_Info=parse_url($URL);
  6.  
  7.  // Building referrer
  8.  if($referrer==&#092;"\") // if not given use this script as referrer
  9.  $referrer=$_SERVER[&#092;"SCRIPT_URI\"];
  10.  
  11.  // making string from $data
  12.  foreach($data as $key=>$value)
  13.  $values[]=&#092;"$key=\".urlencode($value);
  14.  $data_string=implode(&#092;"&\",$values);
  15.  
  16.  // Find out which port is needed - if not given use standard (=80)
  17.  if(!isset($URL_Info[&#092;"port\"]))
  18.  $URL_Info[&#092;"port\"]=80;
  19.  
  20.  // building POST-request:
  21.  $request.=&#092;"POST \".$URL_Info[\"path\"].\" HTTP/1.1n\";
  22.  $request.=&#092;"Host: \".$URL_Info[\"host\"].\"n\";
  23.  $request.=&#092;"Referer: $referern\";
  24.  $request.=&#092;"Content-type: application/x-www-form-urlencodedn\";
  25.  $request.=&#092;"Content-length: \".strlen($data_string).\"n\";
  26.  $request.=&#092;"Connection: closen\";
  27.  $request.=&#092;"n\";
  28.  $request.=$data_string.&#092;"n\";
  29.  
  30.  $fp = fsockopen($URL_Info[&#092;"host\"],$URL_Info[\"port\"]);
  31.  fputs($fp, $request);
  32.  while(!feof($fp)) {
  33.  $result .= fgets($fp, 128);
  34.  }
  35.  fclose($fp);
  36.  
  37.  return $result;
  38.  }
  39.  
  40.  $output1=HTTP_Post(&#092;"http://www.server1.com/script1.php\",$_POST);
  41.  $output2=HTTP_Post(&#092;"http://www.server2.com/script2.php\",$_POST);
  42. ?>
Go to the top of the page
+Quote Post
-JohnyVox-
post
Post #6





Goście







Proszę o jakichś przykład przesłania z pliku 1.php do 2.php kilku zmiennych i odebranie ich, bo nie bardzo kumam. sadsmiley02.gif
Go to the top of the page
+Quote Post
-JohnyVox-
post
Post #7





Goście







Już nie wierzę, że nikt nie wie! withstupidsmiley.gif tongue.gif
Go to the top of the page
+Quote Post
mynio
post
Post #8





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 25.03.2005

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


rzuce linkiem, bo sprawa jest opisana:
http://www.haxite.org/index.php3?site=arty...kul_view&id=244

pzdr
Go to the top of the page
+Quote Post
crash
post
Post #9





Grupa: Przyjaciele php.pl
Postów: 2 196
Pomógł: 2
Dołączył: 17.01.2004
Skąd: Sosnowiec

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


Cytat(JohnyVox @ 2005-05-18 16:56:49)
Już nie wierzę, że nikt nie wie! withstupidsmiley.gif  tongue.gif

Dostałeś trzy gotowe rozwiązania i jeszcze Ci mało?...


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 19.08.2025 - 11:49