How to pass POST data to php-cgi

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

 



Hi,

I'm writing a simple httpd with php support via cgi/fastcgi. I tried several
ways to pass POST data to php-cgi (by writing to child process's stdin from
parent process), however, none of them worked

Here's the most simple not working example:

$ export CONTENT_LENGTH=4; export HTTP_METHOD=POST; echo 's=33' | php-cgi
test.php

and test.php has only one line:

<?php echo $_POST["s"]; ?>

Running it gave me:

X-Powered-By: PHP/5.2.3-1ubuntu6.3
Content-type: text/html

<br />
<b>Notice</b>:  Undefined index:  s in <b>/home/chen/temp/test.php</b> on
line <b>1</b><br />

Please help me figure out what's missing. Part of php-cgi's phpinfo() output
is attached, I will provide more if you need.

Thanks in advance,
Hui

=========phpinfo() output==========
_SERVER["TERM"]xterm
_SERVER["SHELL"]/bin/bash
_SERVER["SSH_TTY"]/dev/pts/1
_SERVER["CONTENT_LENG"]4
_SERVER["LD_LIBRARY_PATH"]/usr/local/lib
_SERVER["LS_COLORS"]no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.flac=01;35:*.mp3=01;35:*.mpc=01;35:*.ogg=01;35:*.wav=01;35:
_SERVER["LANG"]en_US.UTF-8
_SERVER["HISTCONTROL"]ignoredups
_SERVER["SHLVL"]1
_SERVER["CONTENT_LENGTH"]4
_SERVER["LESSOPEN"]| /usr/bin/lesspipe %s
_SERVER["HTTP_METHOD"]POST
_SERVER["CONTENT_TYPE"]application/x-www-f­orm-urlencoded
_SERVER["LESSCLOSE"]/usr/bin/lesspipe %s %s
_SERVER["_"]/usr/bin/php-cgi
_SERVER["PHP_SELF"]<i>no value</i>
_SERVER["REQUEST_TIME"]1205702297
_SERVER["argv"]</td><td class="v"><pre>Array
(
    [0] =&gt; phpinfo.php
)
</pre>

_SERVER["argc"]1
_ENV["TERM"]xterm
_ENV["SHELL"]/bin/bash
_ENV["SSH_TTY"]/dev/pts/1
_ENV["CONTENT_LENG"]4
_ENV["LD_LIBRARY_PATH"]/usr/local/lib
_ENV["LS_COLORS"]no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.flac=01;35:*.mp3=01;35:*.mpc=01;35:*.ogg=01;35:*.wav=01;35:
_ENV["LANG"]en_US.UTF-8
_ENV["HISTCONTROL"]ignoredups
_ENV["SHLVL"]1
_ENV["CONTENT_LENGTH"]4
_ENV["LESSOPEN"]| /usr/bin/lesspipe %s
_ENV["HTTP_METHOD"]POST
_ENV["CONTENT_TYPE"]application/x-www-f­orm-urlencoded
_ENV["LESSCLOSE"]/usr/bin/lesspipe %s %s
_ENV["_"]/usr/bin/php-cgi

[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