Re: HTTP POST into PHP

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: June Tate
Date:  
To: plug-discuss
Subject: Re: HTTP POST into PHP
This is probably a question better addressed to the AzPHP mailing list
instead of PLUG discuss. You can find it at http://www.azphp.org/

Craig White wrote:
| Trying to figure out what is exactly POST'ed to a php file when executed
| from a form. Perhaps my problem is that from the 'sender' I have several
| 'form' objects, each with an 'input' button to invoke the action.


I do this internally on our systems all the time and don't generally
have issues. The only fields that are posted to a page are the ones that
are inside of the <form> tag that has the button that was pressed.

Using the example XHTML code:

~  <form method="post" action="test.php">
~    <input type="text" name="foo" />
~    <input type="submit" value="Button 1" />
~  </form>


~  <form method="post" action="test.php">
~    <input type="text" name="bar" />
~    <input type="submit" value="Button 2" />
~  </form>


If a user clicks on Button 2, then only the text field "bar" is posted
to bar.php -- "foo" is ignored.

| anyway, I have tried to inspect the contents of of the POST by simple
| commands in my target.php file with

|
| var_export($_POST);
| var_export($_HTTP_POST_VARS);


$HTTP_POST_VARS is deprecated as of PHP4 -- avoid it like the plague, if
you can.

| but the thing that is really making me crazy is if I have two
| consecutive lines...

|
| $action = $_POST['OK'];
| var_export($_POST['OK']);

|
| will return different values.

|
| It's almost as if the value of $_POST['OK'] will never die - even if I
| change the 'name' of all of the '<input name="OK" value="some_value">
| buttons.


It's really hard to tell what you're trying to do without seeing both
PHP code and accompanying HTML, so I can't comment on this one.

| So I am really left to think that the above 'var_export' commands simply
| don't give me a complete dump of all of the data that is POST'ed - is
| there any way to get a complete dump of this data?


You can try several other methods. Try these:

~ 1. echo "<pre>". print_r($_POST) ."</pre>";
~ 2. echo "<pre>". var_dump($_POST) ."</pre>";
~ 3. foreach ($_POST AS $key => $val) { echo "$key => $val<br />" }

Note that if you're using PHP3 instead of PHP4, you'll need to replace
$_POST with $HTTP_POST_VARS instead.

HTH

- --
June Tate * http://www.theonelab.com *
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss