Problem pulling values from product form
Posted: Tue Sep 21, 2010 2:09 pm
I have been working on a catalog application. I am having trouble with transferring the information of a product (which are displayed from the database, each in it's own form). When I check to see if the form (from the product) has been submitted so I can transfer the variables to a cookie to send to the shopping cart the product name variable is not set.
I want to get the product name variable from the form to the bottom of the code in the if isset submitted section.
Any help would be greatly appreciated.
Here is the code from the section I am having problems with. It may be important to note that I have a form that creates product categories earlier in the code that also uses the POST array however I am still having issues even using the GET array.
I want to get the product name variable from the form to the bottom of the code in the if isset submitted section.
Any help would be greatly appreciated.
Here is the code from the section I am having problems with. It may be important to note that I have a form that creates product categories earlier in the code that also uses the POST array however I am still having issues even using the GET array.
Code: Select all
$cxn = connectDatabase();
$query = "SELECT * from ProductInformation WHERE product_category='$value'";
//setting variable result to the results of the mysql query of the cxn and query information
$result = mysqli_query($cxn,$query) or die("Can't execute query");
$rows = mysqli_num_rows($result);
for ($j = 0 ; $j < $rows ; ++$j)
{
$row = mysqli_fetch_row($result);
$productname = $row[0];
echo '<form id="product" name="product" method="POST" action="ProductCatalog.php">';
echo '<table width="400" border="1">';
echo '<tr><td>' . $row[0] . '</td>';
echo '<td>' . $row[1] . '</td></tr>';
echo '<tr><td colspan="2">Price: $' . $row[2] . '<td></tr>';
echo '<tr><td>' . $row[3] . '</td>';
echo '<td><img src="' . $row[4] . '"/></td></tr>';
echo '<tr><td colspan="2"><input type="hidden" name="submitted" value="yes">';
echo '<input type="hidden" value="';
$productname;
echo '" name="product_name">';
echo '<input type="submit" value="submit"></td></tr>';
echo '</table></form>';
}//check if product is set
if(isset ($_POST['submitted']) and $_POST['submitted'] =="yes"){
echo "It has been submitted";
echo $_POST['product_name'];
//if product is selected proccess information from the product form and transfer to shopping cart
}