Sending post data and going to that page..

From: Date: Sun, 13 Apr 2003 17:04:03 +0000
Subject: Sending post data and going to that page..
Groups: php.general 
Request: Send a blank email to php-general+get-143676@lists.php.net to get a copy of this message
Hi, I need to be able to send POST data to a page and found the following function on the net: 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\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,128); fclose($fp); return $buf; } The problem with this function is that it will send the post data and stay on the current page as far as I can tell. I need something that will redirect the user to this page and send the post data along with it. Can I just add a Location header to this function to redirect the user to that page? Thanks, Leo

« previous php.general (#143676) next »