Re: [PHP] Can't fetch HTTP POST data in PHP?

From: Chris Shiflett (shiflett_at_php.net)
Date: 11/16/03


Date: Sat, 15 Nov 2003 17:31:01 -0800 (PST)
To: Arne Rusek <zonk@matfyz.cz>, php-general@lists.php.net


--- Arne Rusek <zonk@matfyz.cz> wrote:
> I used this form:
>
> <form action="test.php" method="POST">
> Your name: <input type="text" name="username"/><br/>
> Email: <input type="text" name="email"/></br>
> <input type="submit" name="submit" value="Submit me!">
> </form>
>
> The test.php script contained this code:
>
> <?php
> error_reporting(E_ALL);
> echo "<pre>\n";
> phpinfo();
> echo "</pre>\n<br/>";
> var_dump($_POST);
> ?>
>
> Then I saw a pretty large page but at the end there was
>
> array(0) { }
>
> and _that_ seemed to me pretty strange.

That does seem strange. I glanced at this page of yours:

> http://zonk.matfyz.cz/php_post_problem

And I saw this:

REQUEST_METHOD => GET

So, why was the request a GET request rather than a POST request? There is
no content nor any entity headers either, so it doesn't seem like this
line (telling us that the request method was GET) is wrong.

However, I also don't see any URL variables, so it doesn't seem like the
HTTP request contained any form data, whether GET or POST.

> http://zonk.matfyz.cz/php_get_problem

This looks a bit better. We still have a GET request method, and the query
string has something:

QUERY_STRING => username=zonk&email=zonk&submit=Submit+me%21

However, I can't explain why a print_r($_GET) would not display the
username, email, and submit form variables. Maybe you can try:

echo $username;
echo $_GET['username'];
echo $_POST['username'];
echo $_REQUEST['username'];
echo $_SERVER['QUERY_STRING'];

Hopefully one of this will output something relevant. Otherwise, I suppose
it's possible that there is a bug in the CGI SAPI, unless I'm missing
something.

Hope that helps.

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
     Coming mid-2004
HTTP Developer's Handbook
     http://httphandbook.org/
RAMP Training Courses
     http://www.nyphp.org/ramp



Relevant Pages

  • dhclient doesnt respond to DHCP OFFER
    ... It has two pcmcia nework cards - one connected to ... Echo (ping) request ...
    (comp.os.linux.networking)
  • Re: Re: How to get an parameter from a remote php script?
    ... > echo $t; ... > does something with this request.. ... > Or, in case you don’t need to store the remote file in a variable, ... Visit Topic URL to contact author (reg. ...
    (comp.lang.php)
  • Re: ssh on ping port?
    ... REQUEST and receives ICMP ECHO REPLY. ... Please do not confuse an icmp packet with a tcp and/or udp packet. ... The icmp protocol do NOT use the notation of ports, instead the icmp protocol is divided into different types where echo request is type 8 and echo reply is type 0. ... Both will use port 7 if that is what /etc/services says to use. ...
    (alt.os.linux)
  • Re: So you think you are (or wanna be) a hacker
    ... >>properly calculating the amount of storage to request takes care of that. ... use snprintf or do something else. ... summer@Dolphin:~$ echo $HOME ...
    (Debian-User)
  • Re: [PHP] header("Location: page.php") not redirecting
    ... I meant to try using a full URL first, then use echo if it still doesn't ... :-) This shouldn't work as it is, because you have output prior to ... Chris Shiflett - http://shiflett.org/ ... PHP Security Handbook ...
    (php.general)