[ previous ] [ next ] [ threads ]
 
 From:  overbored <overbored at overbored dot net>
 To:  m0n0wall at lists dot m0n0 dot ch
 Subject:  PHP and mini_httpd: POST not working
 Date:  Mon, 28 Feb 2005 21:04:26 -0800
Hi all, I'm learning PHP and I'd like to use m0n0wall's PHP code to 
create a similar Web-based ifconfig tool for a Soekris box (running 
Pebble). However, I've been unsuccessful at getting PHP working with 
mini_httpd. In particular, the POST data is not being received. Here's 
what I did...

First, I applied (only) the SCRIPT_FILENAME and index.php modifications 
to mini_httpd.c, as suggested in an earlier post:

http://m0n0.ch/wall/list/?action=show_msg&actionargs[]=15&actionargs[]=11

Then I built & installed this on a (regular) Debian box, which had php4 
installed from apt. (This doesn't seem related, but for some reason, 
when I start up, I get a warning: "socket: Address family not supported 
by protocol".)

Next, I modified index.php from m0n0wall, and that seemed to work fine. 
But then I modified interfaces_lan.php, and I found that POST data isn't 
getting through at all. Googling didn't really turn up much.

I've attached a simple test.php that doesn't work (always prints "no 
post"), along with my /etc/php4/cli/php.ini. (Sorry for the .zip, but 
I'm getting rejected by the list for having a message of length > 30K.) 
If you uncomment the stdin-reading lines, the server won't respond (I 
think because it's trying to read stdin that's not there, or that has no 
EOF.) Here is the page's initial output:

HTTP_ENV_VARS:
/usr/local/bin:/usr/ucb:/bin:/usr/bin
/usr/local/lib:/usr/lib
mini_httpd/1.19 19dec2003
dell400
CGI/1.1
HTTP/1.0
8000
GET
/test.php
/home/a/web/htdocs/localhost/test.php
192.168.1.101
Opera/7.54u1 (Windows NT 5.1; U) [en]
192.168.1.104:8000

And here is its output after a submit (when I set method to "post"):

HTTP_ENV_VARS:
/usr/local/bin:/usr/ucb:/bin:/usr/bin
/usr/local/lib:/usr/lib
mini_httpd/1.19 19dec2003
dell400
CGI/1.1
HTTP/1.0
8000
POST
/test.php
/home/yang/web/htdocs/localhost/test.php
192.168.1.101
http://192.168.1.104:8000/test.php
Opera/7.54u1 (Windows NT 5.1; U) [en]
192.168.1.104:8000
application/x-www-form-urlencoded
22

Here is its output when I set method to "get":

HTTP_ENV_VARS:
/usr/local/bin:/usr/ucb:/bin:/usr/bin
/usr/local/lib:/usr/lib
mini_httpd/1.19 19dec2003
dell400
CGI/1.1
HTTP/1.0
8000
GET
/test.php
/home/a/web/htdocs/localhost/test.php
alpha=asdfasdfβ=Submit
192.168.1.101
http://192.168.1.104:8000/test.php
Opera/7.54u1 (Windows NT 5.1; U) [en]
192.168.1.104:8000

Basically, _POST/_GET/_REQUEST never exist, and it seems the only way I 
can get the data is with GET and parsing the HTTP_ENV_VARS.

I've also tried with different browsers. What's going on? Any help would 
be tremendously appreciated. Thanks in advance.
files.zip (18.1 KB, application/x-zip-compressed)