Re: Re: Authentication fails - SOLVED

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

 



On 3/4/2005 2:02 PM Richard Lynch wrote:
John Swartzentruber wrote:

I stripped down my original script until it started receiving POST data,
then I kept modifying it until I figured out where the problem was. I
found it, but I'm still as clueless as every.

To summarize: I have a form that posts to the same script that contains
the form. In its original state, when the script is called after I
submit the form data, the $_POST[] data is completely empty and the
_SERVER variable that indicates the type of data is set to "GET".

In the script is the following code:

if (IsSet($_POST["action"])) {
//    $action = $_POST["action"];
} else {
    $action = $_GET["action"];
}


Normally the second line is not commented. When I comment out that line, then the $_POST array has all of the data I would expect it to. When it is not commented, then it does not work.

Just to make sure that I am really confused, this bit of code is *after*
the call to var_dump($_POST), but *before* the code that creates the form.

Does anyone have any ideas about why setting this variable has such a
large and seemingly unrelated affect?


WILD GUESS:
Somewhere in your form and/or the logic, you are sending GET data for
$action as well as POST data for $action, and you are confusing the two.

Show us your stripped-down but still-broken code.

I think I found it. I was very, very confused by the fact that changing a single line seemed to retroactively affect code that was *before* that line. Just a bit ago, it struck me that I should look at header() calls, since that would make the file reload and in affect retroactively change the previous code. I commented out each header() call, and the POST variables came through correctly. Then I narrowed it down to a single one (which was the one I suspected in the first place). It made sense when the header() call caused the page to reload, it wouldn't have POST data. Then I needed to figure out what the code was supposed to do.


Voila, right above the header() call and the exit, were four calls to "session_register()". Aha, now I have something to R in TFM.

Yup, you guessed it. I have register_globals disabled, as is the default. The script was written assuming that the session data would be global. The session data basically disappeared as far as the script was concerned. So it turns out that having the POST data disappear was intentionally, but having the session data disappear was the problem.

Another example of the problems a newbie can have when debugging someone else's code.

Thanks for sticking with me.

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


[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