Re: Re[2]: [PHP] sending header but not leaving page

From: Date: Mon, 05 May 2003 07:27:04 +0000
Subject: Re: Re[2]: [PHP] sending header but not leaving page
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-146405@lists.php.net to get a copy of this message
Okay I'm glad to hear you need my help on this question, because i have found a solution: /* sendToHost * ~~~~~~~~~~ * Params: * $host - Just the hostname. No http:// or /path/to/file.html portions * $method - get or post, case-insensitive * $path - The /path/to/file.html part * $data - The query string, without initial question mark * $useragent - If true, 'MSIE' will be sent as the User-Agent (optional) * * Examples: * sendToHost('www.google.com','get','/search','q=php_imlib'); * sendToHost('www.example.com','post','/some_script.cgi', * 'param=First+Param&second=Second+param'); */ function sendToHost($host,$method,$path,$data,$useragent=0) { // Supply a default method of GET if the one passed was empty if (empty($method)) $method = 'GET'; $method = strtoupper($method); $fp = fsockopen($host,80); if ($method == 'GET') $path .= '?' . $data; fputs($fp, "$method $path HTTP/1.1\n"); fputs($fp, "Host: $host\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); fputs($fp, "Content-length: " . strlen($data) . "\n"); if ($useragent) fputs($fp, "User-Agent: MSIE\n"); fputs($fp, "Connection: close\n\n"); if ($method == 'POST') fputs($fp, $data); while (!feof($fp)) $buf .= fgets($fp,128); fclose($fp); return $buf; } Let me know if you need anymore help with php :-)) Danielle Rijkeboer "Burhan Khalid" <phplist@meidomus.com> schreef in bericht news:1589359304.20030505021153@meidomus.com... > Hello Danielle, > > Monday, May 5, 2003, 12:56:02 AM, you wrote: > > DR> If it were that easy I wouldn't being posting a question because I know how > DR> to simply redirect.. but the problem is that it MUST redirect > DR> while in the loop and then finish the loop. > > I would love to see you find a solution to this (the way you want it), > because it is quite frankly, a rediculous way of doing it. > > Once you execute header() -- the browser is redirected, but the script > does not stop. However, you are upto your own devices if you want to > find out the results of the part of the script afterwards. > > > -- > Best regards, > Burhan > phplist[at]meidomus[dot]com > >

« previous php.general (#146405) next »