PHP form POST question - PHP

This is a discussion on PHP form POST question - PHP ; I just narrowed something down about forms and POST and would like education. In the following scenarios, all work except #4. $_POST is null. Why is that? Setup: 1) Running on localhost 2) /foo/index.php has the following: <? var_dump($_POST); var_dump($_GET); ...

+ Reply to Thread
Results 1 to 4 of 4

PHP form POST question

  1. Default PHP form POST question

    I just narrowed something down about forms and POST and would like
    education. In the following scenarios, all work except #4. $_POST is
    null. Why is that?

    Setup:
    1) Running on localhost
    2) /foo/index.php has the following:
    <? var_dump($_POST); var_dump($_GET); ?>
    3) /index.php contends vary per scenario (below)

    Running RHEL 3, all updates (PHP 4.3.2).

    SCENARIO 1:
    /index.php contains the following:

    <form method="get" action="/foo/index.php">
    <input name="foobutton" type="submit">
    </form>

    In this case in /foo/index.php $_GET has the right value, i.e.
    array('foobutton' => '');

    SCENARIO 2:
    /index.php contains the following:

    <form method="get" action="/foo">
    <input name="foobutton" type="submit">
    </form>

    In this case in /foo/index.php $_GET has the right value, i.e.
    array('foobutton' => '');

    SCENARIO 3:
    /index.php contains the following:

    <form method="post" action="/foo/index.php">
    <input name="foobutton" type="submit">
    </form>

    In this case in /foo/index.php $_POST has the right value, i.e.
    array('foobutton' => '');

    SCENARIO 4:
    /index.php contains the following:

    <form method="post" action="/foo">
    <input name="foobutton" type="submit">
    </form>

    In this case in /foo/index.php $_POST is NULL.

    HUH? Why is $_POST empty? Is Apache doing something to kill the form's
    post information when it has to resolve /foo to /foo/index.php?

  2. Default Re: [PHP] PHP form POST question

    When you access /foo, the server will redirect the client to /foo/ (because
    it is a directory). At the redirected page, the post data will not be sent
    again by the browser thus there are no _POST values.

    Try using action="/foo/". That may work.



    ----- Original Message -----
    From: "James (IFMS)" <jamesk@ifm-services.com>
    To: <php-general@lists.php.net>
    Sent: Monday, January 10, 2005 10:04 AM
    Subject: [PHP] PHP form POST question


    >I just narrowed something down about forms and POST and would like
    >education. In the following scenarios, all work except #4. $_POST is null.
    >Why is that?
    >
    > Setup:
    > 1) Running on localhost
    > 2) /foo/index.php has the following:
    > <? var_dump($_POST); var_dump($_GET); ?>
    > 3) /index.php contends vary per scenario (below)
    >
    > Running RHEL 3, all updates (PHP 4.3.2).
    >
    > SCENARIO 1:
    > /index.php contains the following:
    >
    > <form method="get" action="/foo/index.php">
    > <input name="foobutton" type="submit">
    > </form>
    >
    > In this case in /foo/index.php $_GET has the right value, i.e.
    > array('foobutton' => '');
    >
    > SCENARIO 2:
    > /index.php contains the following:
    >
    > <form method="get" action="/foo">
    > <input name="foobutton" type="submit">
    > </form>
    >
    > In this case in /foo/index.php $_GET has the right value, i.e.
    > array('foobutton' => '');
    >
    > SCENARIO 3:
    > /index.php contains the following:
    >
    > <form method="post" action="/foo/index.php">
    > <input name="foobutton" type="submit">
    > </form>
    >
    > In this case in /foo/index.php $_POST has the right value, i.e.
    > array('foobutton' => '');
    >
    > SCENARIO 4:
    > /index.php contains the following:
    >
    > <form method="post" action="/foo">
    > <input name="foobutton" type="submit">
    > </form>
    >
    > In this case in /foo/index.php $_POST is NULL.
    >
    > HUH? Why is $_POST empty? Is Apache doing something to kill the form's
    > post information when it has to resolve /foo to /foo/index.php?
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    >


  3. Default Re: [PHP] PHP form POST question

    Hi,

    Monday, January 10, 2005, 12:04:28 PM, you wrote:
    JI> I just narrowed something down about forms and POST and would like
    JI> education. In the following scenarios, all work except #4. $_POST is
    JI> null. Why is that?

    JI> Setup:
    JI> 1) Running on localhost
    JI> 2) /foo/index.php has the following:
    JI> <? var_dump($_POST); var_dump($_GET); ?>
    JI> 3) /index.php contends vary per scenario (below)

    JI> Running RHEL 3, all updates (PHP 4.3.2).

    JI> SCENARIO 1:
    JI> /index.php contains the following:

    JI> <form method="get" action="/foo/index.php">
    JI> <input name="foobutton" type="submit">
    JI> </form>

    JI> In this case in /foo/index.php $_GET has the right value, i.e.
    array('foobutton' =>> '');

    JI> SCENARIO 2:
    JI> /index.php contains the following:

    JI> <form method="get" action="/foo">
    JI> <input name="foobutton" type="submit">
    JI> </form>

    JI> In this case in /foo/index.php $_GET has the right value, i.e.
    array('foobutton' =>> '');

    JI> SCENARIO 3:
    JI> /index.php contains the following:

    JI> <form method="post" action="/foo/index.php">
    JI> <input name="foobutton" type="submit">
    JI> </form>

    JI> In this case in /foo/index.php $_POST has the right value, i.e.
    array('foobutton' =>> '');

    JI> SCENARIO 4:
    JI> /index.php contains the following:

    JI> <form method="post" action="/foo">
    JI> <input name="foobutton" type="submit">
    JI> </form>

    JI> In this case in /foo/index.php $_POST is NULL.

    JI> HUH? Why is $_POST empty? Is Apache doing something to kill the form's
    JI> post information when it has to resolve /foo to /foo/index.php?


    If you do a post to just the domain name apache does a redirect to /foo/index.php
    losing the post info.

    --
    regards,
    Tom

  4. Default Re: [PHP] PHP form POST question

    > When you access /foo, the server will redirect the client to /foo/
    > (because it is a directory). At the redirected page, the post data will
    > not be sent again by the browser thus there are no _POST values.
    >
    > Try using action="/foo/". That may work.


    Yes, /foo/ does work.

    The explanation makes sense.

    Bugger! All that time spent banging my head against the wall. :-)

    Thanks!

+ Reply to Thread