Hi,
Right, I have a problem with storing information for a session variable. I am currently learning php and have just gotten onto session variables. I decided to produce a shop and have an entrance page which the user will enter their email address and name and these are stored in the session. The next page are a set of hypertext links which are created from a MYSQL database. Each one of these links leads onto a product description page which is where i want the user to be able to add the product to their shopping cart, and then the next page shows the shopping carts contents and the user has the ability to return to the shop to pick more. I did the shop with a select list to begin with and it worked fine, but now it is not storing the particular product on the screen....
the code for the displayed product is:
<?php
//include the file containing passowrds and connection information and make connection with database
require('dbdetails.inc');
$query = "SELECT * FROM shop WHERE description='$description'";
$result = mysql_query($query);
if (!$result) {
echo "Error in $query
";
echo mysql_errno().": ".mysql_error()."
"; }
if ($row = mysql_fetch_array($result)) {
echo "<h2>Here is the Data you requested</h2>";
echo "<form method=post name='form_products[]'><table border=0>";
echo "<tr><th align=right>Part Number</th><td align=right>".$row["partno"]."</td></tr>\n";
echo "<tr><th align=right>Description</th><td align=right>".$row["description"]."</td></tr>\n";
echo "<tr><th align=right>Gender</th><td align=right>".$row["gender"]."</td></tr>\n";
echo "<tr><th align=right>Soundbite</th><td align=right>".$row["soundbite"]."</td></tr>\n";
echo "<tr><th align=right>Unit Price</th><td align=right>".$row["unitprice"]."</td></tr>\n";
echo "<tr><th align=right>Quantity</th><td align=right>".$row["quantity"]."</td></tr>\n";
echo "<tr><th align=right>Weight</th><td align=right>".$row["weight"]."</td></tr>\n";
echo "<tr><th align=right>Tax Code</th><td align=right>".$row["taxcode"]."</td></tr>\n";
echo "</table>";
echo "<br/><br/><input type=submit value=\"Add to Cart\">";
echo "</form>\n\n";
?>
And then the code to add the product to the cart is:
<?
if (isset( $form_products ))
{
$cart[] = "description";
// remember the value of products
session_register("cart");
print "<p>Your Selection has been registered !</p>";
}
?>
The actual details i want to store in the session are the product description and the product price, does anyone know how to do this and where i am going wrong with the above code?? I have tried it with a select statement and it worked fine but for some reason i can't get the values from the above form to store (which is what i want)...
Thanks for any help
dave