With the first example you'd have to do string parsing / regexes to get the correct values out so they can be married with other data in your app... whereas with the second example.. you will end up with something like:<?phpvar_dump($_POST['person']);//will get you something like:array (0 => array('first_name'=>'john','last_name'=>'smith'),1 => array('first_name'=>'jane','last_name'=>'jones'),)?>

This is invaluable when you want to link various posted form data to other hashes on the server side, when you need to store posted data in separate "compartment" arrays or when you want to link your POSTed data into different record handlers in various Frameworks.

Remember also that using [] as in index will cause a sequential numeric array to be created once the data is posted, so sometimes it's better to define your indexes explicitly.

For a page with multiple forms here is one way of processing the different POST values that you may receive. This code is good for when you have distinct forms on a page. Adding another form only requires an extra entry in the array and switch statements.

<?php

if (!empty($_POST)) {// Array of post values for each different form on your page.$postNameArr = array('F1_Submit', 'F2_Submit', 'F3_Submit');

// Find all of the post identifiers within $_POST$postIdentifierArr = array();

// Only one form should be submitted at a time so we should have one // post identifier. The die statements here are pretty harsh you may consider // a warning rather than this. if (count($postIdentifierArr) != 1) {count($postIdentifierArr) < 1 or die("\$_POST contained more than one post identifier: " .implode(" ", $postIdentifierArr));

// We have not died yet so we must have less than one.die("\$_POST did not contain a known post identifier."); }

Make sure your submit buttons (ie. <input type="submit"> etc) have a 'value' attribute. If they don't, the value won't appear in $_POST and so isset($_POST["submit"]) won't work either.

Example:

<input type="submit" name="submit">

isset($_POST["submit"]) returns false

<input type="submit" name="submit" value="Next">

isset($_POST["submit"]) returns true.

This might seem obvious for text buttons since they need a label anyway. However, if you are using image buttons, it might not occur to you that you need to set a value attribute as well. For example, the value attribute is required in the following element if you want to be able to detect it in your script.

but to make this $_Post work You Must write in the .HTML file in the form ( action="http://example.php")<form action="http://example.php" method="post">....</form>if you Do Not put http:// before the .php file it will Not work with you>>>Thanks!

Nasty bug in IE6, Apache2 and mod_auth_sspi. Essentially if the user presses the submit button too quickly, $_POST (and the equivalents) comes back empty. The workaround is to set Apache's KeepAliveTimeout to 1. This would mean that the user would need to push submit within a second to trigger the issue.