Re: Problem submitting a POST request "by hand"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The problem is that the URL which I posted to doesn't display in a browser again. I want to do the following:
1) www.someserver.com/feedback.phtml sends the user-entered form data to www.someserver.com/mailer.php
2) www.someserver.com/mailer.php (the example below) checks these data and submits resulting parameter list via POST method back to www.someserver.com/feedback.phtml and loads it again
3) www.someserver.com/feedback.phtml displays again in a browser according to received POST parameters...
PROBLEM: www.someserver.com/feedback.phtml doesn't load again (a blank page is displayed). I discovered by accidant that if I add the echo $c; line then the page loades but the &c value's string is seen on the top. How can I get the www.someserver.com/feedback.phtml loaded again without this trick?


Vallo

Jochem Maas wrote:
Vallo Reima wrote:

Hello!

I send the parameters from one php script to another via POST method. The solution works (see example below) but the receiver page loads ONLY if I include the echo $c; command after send_host (see PROBLEM!!! line).



AFAICS $c contains the response output of the URL which you POSTed to using fputs() - which is the return value of send_host(), so unless you echo the contents of $c (assuming you are not outputting anything else) you will not see the output returned when you do a POST request to the URL passed to the send_host() function ...

I might be missing the point completely, but what exactly is the problem?
you seem to do a POST hit on a url get some output returned and then display
this as if it were your own page... and that seems to be what you want it to do...?


rgds & not-quite-seeing-the-problem,
Jochem

Otherwise a blank page loads without any error messages. The problem is same with Microsoft-IIS/5.1-PHP/5.0.3 and Apache/2.0.51-PHP/4.3.10... What can I do to get rid of this?
Thanks!
Vallo


function send_host($host,$path,$query,$others=''){
$d="POST $path HTTP/1.1\r\nHost: $host\r\nContent-type: application/x-www-form-urlencoded\r\n${others}User-Agent: Mozilla 4.0\r\nContent-length: ".strlen($query)."\r\nConnection: close\r\n\r\n$query";
if (!$h = fsockopen($host,80)) {
return -1;
}
else {
stream_set_timeout($h,10);
}
if (fputs($h,$d) === FALSE) {
return -2;
} else {
$r = '';
while(!feof($h)) {
$r .= fgets($h, 128);
}
}
if (fclose($h) === FALSE) {
return -3;
}
else {
return $r;
}
}


/* ... */

$c = send_host("$host_name","$redirect","$par");
if ($c < 0) {
   echo "<B>ERROR $c</B>";
} else {
   echo $c; /* PROBLEM!!! */
}


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux