Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Jak pobrać dane z $_POST
Lacki2006
post
Post #1





Grupa: Zarejestrowani
Postów: 107
Pomógł: 0
Dołączył: 3.03.2012

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


Witam
Mam taki problem
potrzebuję w jakiś sposób wysłać dane w zmiennych poprzez $_POST ale bez formularza wysyłającego tylko bezpośrednio ze strony tz.
mam zmienne na stronie strona1.php
$pozycja_1 = '1';
$pozycja_2 = '2';
Przechodzie na drugą strone poprzez header('Location: strona2.php');
w pliku strona2.php muszę pobrać te zmienne metodą post czyli
$pozycja_1 = $_POST['1'];
$pozycja_2 = $_POST['2'];
niestety nie mogę tego zrobić poprzez $_GET
Czy da się w ten sposób jakoś przesłać te dane aby odebrały je zmienne POST ?

Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Kshyhoo
post
Post #2





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




  1. <?php
  2. /* sendToHost
  3.  * ~~~~~~~~~~
  4.  * Params:
  5.  * $host - Just the hostname. No http:// or /path/to/file.html portions
  6.  * $method - get or post, case-insensitive
  7.  * $path - The /path/to/file.html part
  8.  * $data - The query string, without initial question mark
  9.  * $useragent - If true, 'MSIE' will be sent as the User-Agent (optional)
  10.  *
  11.  * Examples:
  12.  * sendToHost('www.google.com','get','/search','q=php_imlib');
  13.  * sendToHost('www.example.com','post','/some_script.cgi',
  14.  * 'param=First+Param&second=Second+param');
  15.  */
  16. function sendToHost($host,$method,$path,$data,$useragent=0) {
  17. // Supply a default method of GET if the one passed was empty
  18. if (empty($method))
  19. $method = 'GET';
  20. $method = strtoupper($method);
  21. $fp = fsockopen($host,80);
  22. if ($method == 'GET')
  23. $path .= '?' . $data;
  24. fputs($fp, "$method $path HTTP/1.1\r\n");
  25. fputs($fp, "Host: $host\r\n");
  26. fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
  27. if ($method == 'POST')
  28. fputs($fp, "Content-length: " . strlen($data) . "\r\n");
  29. if ($useragent)
  30. fputs($fp, "User-Agent: MSIE\r\n");
  31. fputs($fp, "Connection: close\r\n\r\n");
  32. if ($method == 'POST')
  33. fputs($fp, $data);
  34.  
  35. while (!feof($fp))
  36. $buf .= fgets($fp,128);
  37. fclose($fp);
  38. return $buf;
  39. }
  40. ?>
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: 3.10.2025 - 20:56