...

View Full Version : push to session variable overwrites



turpentyne
07-31-2012, 11:37 PM
I know, know, know I'm probably doing something wrong here, but one thing at a time.

On a form submission that sends only one _POST item, I reload the page, and I want to push that "_POST" data into a Sessions variable.
and have something like: Array ( [Category1] => information1 )

Then when they make a choice on the page, the second time, I want the process to repeat, and add the variable to get:

Array ( [Category1] => information1, [Category2] => information2 )


Doing it this way, it works, but it overwrites the variable, instead of just adding to it. On the second reload, I just get:
Array ( [Category2] => information2 )

CORRECTION: I get an empty array. nothing's going into the SESSIOn variable

My challenge is that I don't know what the _POST name/key will be, because it's generated by a database query, and a loop. At least at my experience level, I don't know of a way to get that information.

This is the Session bit, I'm trying unsucessfully to use:



<?php
session_start();

if(!isset($_SESSION['options_picked'])){
$_SESSION['options_picked'] = array();
}

if (isset($_POST)) {
// I don't know how to get: $_POST['unknown-variable'];

$testtitt = $_POST;

}

$_SESSION['names'][] = $testtitt;
// I also tried array_push. Same result.

print_r($_SESSION['options_picked']); // for testing result.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum