Envio de variables POST x PHP

Aqui hay un espacio para los amantes del lenguaje PHP

Envio de variables POST x PHP

Notapor Abducted » Vie Jun 23, 2006 2:30 am

Lo que necesito es enviar variables por post (como si fueran enviadas mediante un formulario) a varias paginas (de sitios externos), supongamos que son 3 (pero pueden ser mas). No puede ser mediante un formulario, debe ser automatico cuando cargo la pagina ... ni bien se carga la pagina eso tiene q enviar datos de 3 variables hacia 3 sitios distintos (no puedo mandar las variables en la url, lo aclaro).

Alguien tiene idea de como puedo hacer ?
Abducted
Novato
Novato
 
Mensajes: 2
Registrado: Vie Jun 23, 2006 2:28 am


Re: Envio de variables POST x PHP

Notapor latindev » Vie Jun 23, 2006 9:26 am

Imagen
Avatar de Usuario
latindev
Administrador
Administrador
 
Mensajes: 1062
Registrado: Lun Jun 02, 2003 8:30 pm
Ubicación: Peru


Notapor Abducted » Vie Jun 23, 2006 8:07 pm

No encuentro informacion util en ese link que me enviaste ...
Abducted
Novato
Novato
 
Mensajes: 2
Registrado: Vie Jun 23, 2006 2:28 am

Re: Re: Envio de variables POST x PHP

Notapor Gildus » Dom Jun 25, 2006 9:54 pm

Holas,

de ese link que te dio puedes usar la funcion "fsockopen" para que envies las veces que deseas a distintas direcciones con la funcion que te mencione.

http://www.php.net/manual/es/function.fsockopen.php

por ejemplo:

Código: Seleccionar todo
  1.  

  2. <?php

  3.        // get the necessary data

  4.        $file_name = $_FILES['userfile']['name'];    // the file

  5.        $tmp_name = $_FILES['userfile']['tmp_name'];    // the file

  6.        $content_type = $_FILES['userfile']['type'];    // the file mime type

  7.        

  8.        srand((double)microtime()*1000000);

  9.        $boundary = "---------------------".substr(md5(rand(0,32000)),0,10);

  10.        

  11.        // Build the header

  12.        $header = "POST $remote_url HTTP/1.0\r\n";

  13.        $header .= "Host: $remote_server\r\n";

  14.        $header .= "Content-type: multipart/form-data, boundary=$boundary\r\n";

  15.        // attach post vars

  16.        foreach($_POST AS $index => $value){

  17.            $data .="--$boundary\r\n";

  18.            $data .= "Content-Disposition: form-data; name=\"".$index."\"\r\n";

  19.            $data .= "\r\n".$value."\r\n";

  20.            $data .="--$boundary\r\n";

  21.        }

  22.        // and attach the file

  23.        $data .= "--$boundary\r\n";

  24.        $content_file = join("", file($tmp_name));

  25.        $data .="Content-Disposition: form-data; name=\"userfile\"; filename=\"$file_name\"\r\n";

  26.        $data .= "Content-Type: $content_type\r\n\r\n";

  27.        $data .= "".$content_file."\r\n";

  28.        $data .="--$boundary--\r\n";

  29.        $header .= "Content-length: " . strlen($data) . "\r\n\r\n";

  30.                  // Open the connection

  31.        $fp = fsockopen($remote_server, 80);

  32.        // then just

  33.        fputs($fp, $header.$data);

  34.        fclose($fp);

  35. ?>

  36.  




:wink:


Saludos
Gildus
Código: Seleccionar todo
  1.  

Gildus
Colaborador
Colaborador
 
Mensajes: 191
Registrado: Mar Jun 17, 2003 12:23 pm


    

Volver a PHP

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 0 invitados