Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

PHP:

How can i create an array containing all field names and values from a posted form.      
I then need to save the array as a session for later use.

The code i have works for storing the field input names, just not their submitted values.

Thanks for any help
$fields = array();
foreach ($_POST as $field => $value){
	array_push($fields, $field); 
} 
$_SESSION['fields'] = $fields;

Open in new window

0
ticallian
Asked:
ticallian
1 Solution
 
mostartCommented:
try this:
$fields = array();
foreach ($_POST as $field => $value){
        $fields[$field] = $value; 
} 
$_SESSION['fields'] = $fields;

Open in new window

0
 
ticallianAuthor Commented:
Perfect!
Thanks
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now