views:

89

answers:

4

I am trying to create a form where there are multiple sections. It is actually an online menu ordering system. If you remain on the same section (say.. Appetizer), the values successfully load into $_SESSION and displays in the textbox as value. However, if you switch sections (say.. Soups), the values first loads. But when you submit your order for that particular section/switch sections, it loses the values from Appetizer.

It seems like my session array can only retrieve values from the POST array and fails to retain the values stored in it originally.

can someone tell me what I did wrong? I'm relatively new at this.

This is where the code is...

+1  A: 
session_start();

on top of all pages?

Luis Junior
yes, I have it. There is only one php file anyway
Melody
+1  A: 

Well, let's make sure that sessions are actually working on your server. Try out this snippet of code in it's own file. Refresh it a few times. The counter should increment every time. Does it? Are there any errors reported?

<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_erorrs', true);
session_start();

if(!array_key_exists('counter', $_SESSION))
    $_SESSION['counter'] = 0;

echo "You have visited this page " . $_SESSION['counter'] . "times.";
exit;
Charles
A: 

i think ur overwriting all the values into ur session.so the second time u store the previous value gets nullified. try only to store the values of the item name and quantity .i think this will help

chinni776
A: 

Thanks everyone for your answers. So it turns out the server ran out of space. I tested the code on a different server and it worked just fine!

Melody