Re: =sessions / J. Meloni Textbook=

From: Date: Tue, 18 Nov 2003 23:54:00 +0000
Subject: Re: =sessions / J. Meloni Textbook=
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-170208@lists.php.net to get a copy of this message
Anthony Ritter wrote:
I'm using the script and no values show up in the page: session_bb.php after I submit the values in the <select> form. If somebody would like to test both scripts (session_aa.php and session_bb.php) and get back to me I would be grateful.
I think you're using a crappy book... :) Main PHP part of session_aa.php: ..................... <?php if(isset($_POST['form_products']) && is_array($_POST['form_products'])) {
    if(empty($_SESSION['products']))
    { $_SESSION['products'] = array(); }
    $_SESSION['products'] = array_unique(array_merge($_SESSION['products'],$_POST['form_products']));
    print "<p>Your products have been registered!</p>";
} ?> Main PHP part of session_bb.php: ..................... <?php if(isset($_SESSION['products'])) { print "<b>Your cart:</b><ol>\n"; foreach($_SESSION['products'] as $p) {
       print "<li>$p</li>";
} print "</ol>"; } ?> Remember to have session_start() on both pages... Also notice, like I said, there's no need to even make a $products array... Hope that helps. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#170208) next »