Re: =sessions / J. Meloni Textbook=

From: Date: Tue, 18 Nov 2003 23:34:07 +0000
Subject: Re: =sessions / J. Meloni Textbook=
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-170199@lists.php.net to get a copy of this message
Thanks John and others. 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. As I said, these were from her book/CD. Thank you. TR ..................................... // this is session_aa.php script <?php session_start(); ?> <html> <head> <title>Listing 16.4 Storing an array with a session</title> </head> <body> <h1>Product Choice Page</h1> <?php if (isset($_POST[form_products])) { if (!empty($_SESSION[products])) { $products = array_unique( array_merge($_SESSION[products], $_POST[form_products])); } $_SESSION[products] = $products; print "<p>Your products have been registered!</p>"; } ?> <form method="POST" action="<?php $_SERVER[PHP_SELF] ?>"> <P>Select some products:<br> <select name="form_products[]" multiple size=3> <option>Sonic Screwdriver</option> <option>Hal 2000</option> <option>Tardis</option> <option>ORAC</option> <option>Transporter bracelet</option> </select> <br><br> <input type="submit" value="choose"> </form> <br><br> <a href="session_bb.php">content page</a> </body> </html> .......... // ...and this is session_bb.php script <? session_start(); ?> <html> <head> <title>Listing 16.5 Accessing session variables</title> </head> <body> <h1> Content Page</h1> <?php if (isset($_SESSION[products])) { print "<b>Your cart:</b><ol>\n"; foreach (unserialize($_SESSION[products]) as $p) { print "<li>$p"; } print "</ol>"; } ?> <a href="session_aa.php">Back to product choice page</a> </body> </html>

« previous php.general (#170199) next »