I have a lot of text boxes, check boxes, etc in a form which the user would fill-in and it will take 4 forms or pages. In every page after the user completed filling the forms, I got the value using session. How can I preserve the value that I could retrieve after the completion of all the 4 pages of forms and display it. I already tried to put it in array but when I called this array after the last page/form it was result nothing. Please see the code Please help me and advice Thanks Code after in every page. <? session_start(); $arval = array(); require_once("../include/session.php"); reset ($_POST); while(list($key, $val) = each ($_POST)) { if ($val == "") $val = "NULL"; $arVals[$key] = (get_magic_quotes_gpc()) ? $val : addslashes($val); ?> PHP: session.php <? $_SESSION['SESSION'] = true; // setup a dummy array... $arVals = array("monthdatebenifit"=>"", "daydatebenifit"=>"", "yeardatebenifit"=>""); ?> PHP: I call $arVals['monthdatebenifit'] end echo but no result.
You're not assigning anything to the session, you're just using a regular array. Here's how you want to do it (in simplified code): <?php session_start(); while(list($key, $val) = each ($_POST)) ... $_SESSION[$key] = $val; ... ?> Code (markup): You can't just use any array with a session, you have to use the built-in $_SESSION variable. A tutorial on using PHP sessions: http://www.tizag.com/phpT/phpsessions.php
You need to start the session on each of these 4 pages. there shld be session_start() at the top of each page. Regards.