Re: How to send POST info without a form?

From: Date: Thu, 03 Oct 2002 06:56:42 +0000
Subject: Re: How to send POST info without a form?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-118698@lists.php.net to get a copy of this message
> How can I submit POST information to a php file without using an HTML form? You would try this function (from Rasmus Lerdorf) 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); } with $data_to_send = "formfield1=myfieldvalue1&formfield2=myfieldvalue2"; Regards, Philippe

« previous php.general (#118698) next »