[php] post-vars dmv header en info terugkrijgen

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Hoi,

Via een script (zie hieronder) wil ik POST-vars middels een header sturen naar een bestand test2.php

Maar hoe kan test2.php nu informatie teruggeven aan test1.php (het onderstaande script)?:

test1.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?
function sendToHost($host,$method,$path,$data,$useragent=0)
{
    // Supply a default method of GET if the one passed was empty
    if (empty($method))
        $method = 'POST';
    $method = strtoupper($method);
    $fp = fsockopen($host,80);
    if ($method == 'POST')
        $path .= '?' . $data;
    fputs($fp, "$method $path HTTP/1.1\r\n");
    fputs($fp, "Host: $host\r\n");
    fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
    fputs($fp, "Content-length: " . strlen($data) . "\r\n");
    if ($useragent)
        fputs($fp, "User-Agent: MSIE\r\n");
    fputs($fp, "Connection: close\r\n\r\n");
    if ($method == 'POST') fputs($fp, $data);
    while (!feof($fp))
        $buf .= fgets($fp);
    fclose($fp);
    return $buf;
}

print sendToHost('ww.domeinnaam.nl','post','/search/test2.php','param=First+Param&second=Second+param'); 
?>


test2.php moet dus adhv van de post-vars iets doen en bijvoorbeeld een url teruggeven aan test1.php

Dus in test1.php moet iets komen als (waarbij test2.php bijvoorbeeld 'www.google.com' teruggeeft):

PHP:
1
header("Location: " . sendToHost('ww.domeinnaam.nl','post','/search/test2.php','param=First+Param&second=Second+param'));


Met test1.php zoals hierboven krijg ik (als ik 'print' gebruik) alleen maar de volgende output:
code:
1
HTTP/1.1 200 OK Date: Wed, 07 May 2003 13:41:36 GMT Server: Apache/1.3.27 (Unix) mod_throttle/3.1.2 AuthMySQL/2.20 PHP/4.2.3 mod_ssl/2.8.12 OpenSSL/0.9.6 X-Powered-By: PHP/4.2.3 Connection: close Transfer-Encoding: chunked Content-Type: text/html 22 header("Location: www.google.com") 0

[ Voor 10% gewijzigd door Verwijderd op 07-05-2003 15:43 ]