Re: post without <form>
| From: | Lars Torben Wilson | Date: | Wed, 07 Jul 2004 20:08:25 +0000 |
| Subject: | Re: post without <form> | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-189898@lists.php.net to get a copy of this message | ||
Josh Close wrote:
So basically there is no easy way around this. What I'm trying to do is have a page return to a page that was a couple pages back with the same get info. On the second page I can do $return_url = $_SERVER['HTTP_REFERER']; to get the previous url. But then I need to pass it on to the next page, then that page will return to the $return_url. I think passing via $_SESSION vars or cookies would be easier then doing actual socket posts. If there is an easier way than session or cookies to do this, I'd like to know. -JoshIt's super easy, actually. There's been a wee bit of code floating around the mailing list for 5 or so years for this: function PostToHost($host, $path, $data_to_send) { $fp = fsockopen($host,80); fputs($fp, "POST $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_to_send)."\n"); fputs($fp, "Connection: close\n\n"); fputs($fp, $data_to_send); while(!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } Just modify to suit and you're good to go. Note: you need to URL-encode the data you send into a string before passing it to the above function. Hope this helps, Torben -- Torben Wilson <torben@php.net>