please forgive my confusing title, here is my problem:
What is in my code:
<?php
...
$user = array_filter(array_map('array_filter', $_POST['user']));
...
$submit = isset($_POST['button']) ? trim($_POST['button']) : '';
if ($submit == 'Confirm') {
...do something with $user;
} else if ($submit == 'Cancel') {
...do something else with $user;
}
?>
It appears that when the page is first loaded, $user has been set correctly, however, once the "Confirm" button is clicked, the $name array is lost and cannot be processed. Any idea of how to resolve this will be much appreciated! Many thanks.
an Idea, you need to store it in session. it seems you get $_POST['user']
from previous page/request. variable $_POST
only used for passing variable between page, It will not exist anymore if you reload the page.
do it like:
$user = $_SESSION['user'] = array_filter(array_map('array_filter', $_POST['user']));