RE: [PHP] Question in posting form-data

2004-12-17 Thread Richard Lynch
Yao, Minghua wrote:
 Yes. I did modify the original since I need to send data to a program
 which takes only form-data.
 content-disposition:  came from RFC 2388. I don't think the program can
 take application/x-www-form-urlencoded content. Further help needed.

Try it the old way -- I suspect you broke things by changing it around...

You definitely need the $name= and the urlencode of the value, however.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Question in posting form-data

2004-12-17 Thread Yao, Minghua
Thank you for your reply. I tried the original code. It worked well. But the 
site I am trying to send the data to only takes form-data. That is why I 
modified the code. I tried $name= and urlencode. It didn't help.

-Minghua
-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Fri 12/17/2004 11:27 AM
To: Yao, Minghua
Cc: Erwin Kerk; [EMAIL PROTECTED]
Subject: RE: [PHP] Question in posting form-data
 
Yao, Minghua wrote:
 Yes. I did modify the original since I need to send data to a program
 which takes only form-data.
 content-disposition:  came from RFC 2388. I don't think the program can
 take application/x-www-form-urlencoded content. Further help needed.

Try it the old way -- I suspect you broke things by changing it around...

You definitely need the $name= and the urlencode of the value, however.

-- 
Like Music?
http://l-i-e.com/artists.htm






Re: [PHP] Question in posting form-data

2004-12-16 Thread Erwin Kerk
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Question in posting form-data

2004-12-16 Thread Richard Lynch
You also need to URLEncode the $value, either before you pass it in, or
inside the function itself.

Where did you get this PostToHost function?...

Did you modify it?

Cuz, like, I don't think this one is very good...

Where did that content-disposition:  come from?

And virtually every FORM on the web has more than one input, so you're
going to need to handle that.

Google for PostToHost Rasmus Lerdorf to find the original and compare
it with yours.

Yao, Minghua wrote:
 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:[EMAIL PROTECTED]
 Sent: Thu 12/16/2004 6:30 AM
 To: Yao, Minghua
 Cc: [EMAIL PROTECTED]
 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






-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Question in posting form-data

2004-12-16 Thread Yao, Minghua
Yes. I did modify the original since I need to send data to a program which 
takes only form-data.
content-disposition:  came from RFC 2388. I don't think the program can take 
application/x-www-form-urlencoded content. Further help needed. Thanks.

-Minghua
-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Thu 12/16/2004 11:46 AM
To: Yao, Minghua
Cc: Erwin Kerk; [EMAIL PROTECTED]
Subject: RE: [PHP] Question in posting form-data
 
You also need to URLEncode the $value, either before you pass it in, or
inside the function itself.

Where did you get this PostToHost function?...

Did you modify it?

Cuz, like, I don't think this one is very good...

Where did that content-disposition:  come from?

And virtually every FORM on the web has more than one input, so you're
going to need to handle that.

Google for PostToHost Rasmus Lerdorf to find the original and compare
it with yours.

Yao, Minghua wrote:
 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:[EMAIL PROTECTED]
 Sent: Thu 12/16/2004 6:30 AM
 To: Yao, Minghua
 Cc: [EMAIL PROTECTED]
 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






-- 
Like Music?
http://l-i-e.com/artists.htm






RE: [PHP] Question in posting form-data

2004-12-16 Thread Yao, Minghua
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:[EMAIL PROTECTED]
Sent: Thu 12/16/2004 6:30 AM
To: Yao, Minghua
Cc: [EMAIL PROTECTED]
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





[PHP] Question in posting form-data

2004-12-15 Thread Yao, Minghua
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;
}


$host = my.host;
$path = /path/to/receive.php;
$name = x;
$value = ABC; 


$returnedValue = PostToHost($host, $path, $name, $value);

echo $returnedValue;

?

receive.php goes like this,
?php
echo 'x = '.$_POST['x'].'; br /';
?

I got,
..

Notice:  Undefined index:  x in /export/home/mydir/www/test.php on line 2

x = ; 


It looks like receive.php didn't receive the posted value. Is there anything 
wrong with the program? Thanks in advance for any help.

-Minghua