Foros del Web » Programando para Internet » PHP »

POST sin formulario ni variables ocultas

Estas en el tema de POST sin formulario ni variables ocultas en el foro de PHP en Foros del Web. estoy tratando de enviar datos POST pero sin formulario ni variables ocultas... este es el codigo que tengo hasta ahora... pero me da un error... ...
  #1 (permalink)  
Antiguo 16/06/2009, 07:23
Avatar de farra  
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 1 mes
Puntos: 20
Pregunta POST sin formulario ni variables ocultas

estoy tratando de enviar datos POST pero sin formulario ni variables ocultas...

este es el codigo que tengo hasta ahora... pero me da un error...


Enviapost.php :

Código PHP:
<?php
$hostrn
="http://localhost/test/recibepost.php";
$header "Host: $hostrn"
$header .= "User-Agent: PHP Scriptrn"
$header .= "Content-Type: application/x-www-form-urlencodedrn"
$header .= "Content-Length: ".strlen($vars)."rn"
$header .= "Connection: closernrn"

$fp pfsockopen("tcp://".$host$puerto$errno$errstr30); 

if(
$fp){
 
fputs($fp"POST $uri HTTP/1.1rn"); 
 
fputs($fp$header.$vars); 
 
fwrite($fp$out); 
    if(isset(
$_GET[view])){ 
echo
"

"
;
        while (!
feof($fp)) {
            echo 
fgets($fp128);
        }
echo
"

"

    } 
    
fclose($fp);
echo
"ok";

}else{

echo
"error";

}
?>

Recibepost.php :
Código PHP:
<?php 
if($_POST['algo'] != ''){
    echo 
"Valor: ".$_POST['algo'];
}
?>


el error que me tira es:
Warning: pfsockopen() [function.pfsockopen]: unable to connect to tcp://:0 (Failed to parse address "") in C:\wamp\www\test\enviapost.php on line 17


alguien que me diga como puedo solucionarlo???
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)
  #2 (permalink)  
Antiguo 16/06/2009, 07:39
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: POST sin formulario ni variables ocultas

¿Haz tratado de utilizar cURL?
  #3 (permalink)  
Antiguo 16/06/2009, 07:55
Avatar de farra  
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 1 mes
Puntos: 20
Respuesta: POST sin formulario ni variables ocultas

ya descubri el error, era un error estupido nose como no me di cuenta, ahora modifique un poco el codigo y logre quitar ese error pero ahora me da otro error...
Código PHP:
<?php

$host 
gethostbyaddr($_SERVER['REMOTE_ADDR']);

# working vars
$host 'localhost/test/recibepost.php';
$service_uri '/cgi-bin/processACT';
$vars ='code=22&act=TEST';

# compose HTTP request header
$header "Host: $host\r\n";
$header .= "User-Agent: PHP Script\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen($vars)."\r\n";
$header .= "Connection: close\r\n\r\n";

$fp pfsockopen("http://".$host80$errno$errstr);
if (!
$fp) {
   echo 
"$errstr ($errno)<br/>\n";
   echo 
$fp;
} else {
    
fputs($fp"POST $service_uri  HTTP/1.1\r\n");
    
fputs($fp$header.$vars);
    
fwrite($fp$out);
    while (!
feof($fp)) {
        echo 
fgets($fp128);
    }
    
fclose($fp);
}

?>
el error que me tira es:

Warning: pfsockopen() [function.pfsockopen]: unable to connect to http://localhost/test/recibepost.php:80 (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in C:\wamp\www\test\enviapost.php on line 63
Unable to find the socket transport "http" - did you forget to enable it when you configured PHP? (24)


pero sin embargo tengo activada la extencion http en mi php.ini

nose xq me sigue dando ese error...
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)

Última edición por farra; 16/06/2009 a las 08:11
  #4 (permalink)  
Antiguo 16/06/2009, 08:34
Avatar de farra  
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 1 mes
Puntos: 20
Respuesta: POST sin formulario ni variables ocultas

YA SOLUCIONE....!!!

GRACIAS...


Código PHP:
<?php

$host 
gethostbyaddr($_SERVER['REMOTE_ADDR']);

# working vars
$host 'localhost';
$service_uri '/test/recibepost.php';
$vars ='code=22&act=TEST';
$puerto='80';

# compose HTTP request header
$header "Host: $host\r\n";
$header .= "User-Agent: PHP Script\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen($vars)."\r\n";
$header .= "Connection: close\r\n\r\n";

$fp pfsockopen($host$puerto$errno$errstr);
if (!
$fp) {
   echo 
"$errstr ($errno)<br/>\n";
   echo 
$fp;
} else {
    
fputs($fp"POST $service_uri  HTTP/1.1\r\n");
    
fputs($fp$header.$vars);
    
fwrite($fp$out);
    while (!
feof($fp)) {
        echo 
fgets($fp128);
    }
    
fclose($fp);
}

?>
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:57.