RE: [PHP] Question in posting form-data

From: Date: Thu, 16 Dec 2004 14:58:36 +0000
Subject: RE: [PHP] Question in posting form-data
Groups: php.general 
Request: Send a blank email to php-general+get-204493@lists.php.net to get a copy of this message
Thanks. I changed fputs($fp, "$value\n"); to fputs($fp, "$name=$value\n"); But I still got the same message. -Minghua -----Original Message----- From: Erwin Kerk [mailto:erwin@infofeed.nl] Sent: Thu 12/16/2004 6:30 AM To: Yao, Minghua Cc: php-general@lists.php.net Subject: Re: [PHP] Question in posting form-data Yao, Minghua wrote: > Hi, all, > > I am testing how to post form-data to a host using the following code (test.php): > > <?php > function PostToHost($host, $path, $name, $value) { // Test of posting form-data > $fp = fsockopen($host,80); > > fputs($fp, "POST $path HTTP/1.1\n"); > fputs($fp, "Host: $host\n"); > fputs($fp, "Content-Type: multipart/form-data\n"); > fputs($fp, "content-disposition: form-data; name=$name\n"); > fputs($fp, "Connection: close\n\n"); > > fputs($fp, "$value\n"); > > $res = ""; > while(!feof($fp)) { > $res .= fgets($fp, 128); > } > > fclose($fp); > > return $res; > } Check your function carefully. Where are you using the $name of the value? Nowhere! Therefore the receiving script cannot identify the value as x. Try: fputs($fp, "$name=$value\n"); Erwin

« previous php.general (#204493) next »