RE: Question in posting form-data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx]
Sent: Thu 12/16/2004 6:30 AM
To: Yao, Minghua
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux