Jump to content

form after submit (variable undefined ) ??


tayhaithian

Recommended Posts

Below the 4 variable undetectable how come ?

 

$name=$_Get['name'];    <===Null

$food_id =$_GET['food_id']; <<=== this sounds okay

$quant = $_POST['Quantity']; <==Null

$price = $_POST['price']; <==Null

 

<?php
include ('header.php');
?>
<div id="content">
<?php 


if(isset($_POST['update']))
{


$name=$_Get['name'];
$food_id =$_GET['food_id'];
$quant = $_POST['Quantity'];
$price = $_POST['price'];


include('conn.php');
mysql_query("Delete From `foodsys`.`cusorder` WHERE `cusorder`.`food_id` = '$food_id' ");
mysql_query("INSERT INTO `foodsys`.`cusorder` (`table_id`, `food_id`, `price`, `quantity`, `cusorder_id`) 
VALUES ('', $food_id, $price, $quant, NULL)");

echo $name;
echo $food_id;
echo $quant;
echo $price;

//DELETE FROM `foodsys`.`cusorder` WHERE `cusorder`.`cusorder_id` = 25 LIMIT 1;
//DELETE FROM `foodsys`.`cusorder` WHERE `cusorder`.`cusorder_id` = 26 LIMIT 1;

}

//session_start();

include('conn.php');

$grandtotal = 0;
$data = mysql_query("SELECT table_id, cusorder.food_id, sum(quantity) as Quantity ,price,name 
FROM cusorder,foods where foods.food_id = cusorder.food_id group by cusorder.food_id,price")
or die(mysql_error()); 

//Print "<b>table:</b> ".$row['table_id'] . " ";
echo '<center>';

echo '<table border=0 bgcolor=#99CCFF>';
echo '<tr><td width="200px"><b> Name</b></td><td align="center" width="100px"><b> Food </b></td><td align="center" width="80px"><b> Quantity </b></td><td></td><td width="100px" align="center"><b> Price </b></td><td align="right"><b>Amount</b></td></tr>';
for($i=0;$i<mysql_num_rows($data);$i++) 
{
echo '<form method="POST" action="viewcart.php?food_id=',$row["food_id"],'&','name=',$row['name'],'">';


$row=mysql_fetch_assoc($data);
echo '<tr><td>' .$row['name']. '</td>';

echo '<td align="center"> '.$row['food_id'] . '</td>';
echo '<td align="center">'.$row['Quantity'] . '</td>';


echo '<input type="hidden" name="'.$row['name'].'" value="'.$row['name'].'" />';
echo '<input type="hidden" name="'.$row['food_id'].'" value="'.$row['food_id'].'" />';
echo '<input type="hidden" name="'.$row['Quantity'].'" value="'.$row['Quantity'].'" />';
echo '<input type="hidden" name="'.$row['price'].'" value="'.$row['price'].'" />';



echo '<td> <input name="quant" type=text size=1 /><input type=submit name="update" value="Update"/> </td>';
echo '<td align="center">'.$row['price'].'</td>';
echo '<td align="right"><input type=submit name="remove" value="Remove" />'.$row['price']. '</td></tr>';

$total = $row['price'] * $row['Quantity'];

$grandtotal = $grandtotal + $total; 
$amount = (double)$grandtotal;
//echo $total."<br />";

echo '</ form>';


}
echo '<tr ><td colspan="6" align="right"> TOTAL',' <b> '; 
printf("%01.2f", $grandtotal); 
echo '</b></td></tr><br />';
echo '<tr ><td colspan="6" align="center"><input type="submit" name="checkout" value="CheckOut"> </td></tr>';
echo '</table>';

			//$line_cost = $price * $quantity;
			//$total = $total + $line_cost;

echo '</center>';
?>
</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/141884-form-after-submit-variable-undefined/
Share on other sites

im actually trying kind of methods inorder to get the below variable detectable..

$_get.... $_post .... and even $row['']

 

 

$name=$_Get['name'];    <===Null

$food_id =$_GET['food_id']; <<=== this sounds okay

$quant = $_POST['Quantity']; <==Null

$price = $_POST['price']; <==Null

 

$name=$_Get['name'];    <===Null

change it to $_GET

 

 

$quant = $_POST['Quantity']; <==Null

$price = $_POST['price']; <==Null

You are assigning the value of $row['Quantity'] and $row['price'] as the name in your form fields, instead of the actual names.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.