tayhaithian Posted January 22, 2009 Share Posted January 22, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/141884-form-after-submit-variable-undefined/ Share on other sites More sharing options...
Philip Posted January 22, 2009 Share Posted January 22, 2009 Mixing GET/POST are we? I don't really understand why you're trying to use GET variables when you have the same variables in hidden POST fields. Quote Link to comment https://forums.phpfreaks.com/topic/141884-form-after-submit-variable-undefined/#findComment-742882 Share on other sites More sharing options...
tayhaithian Posted January 22, 2009 Author Share Posted January 22, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/141884-form-after-submit-variable-undefined/#findComment-742886 Share on other sites More sharing options...
.josh Posted January 22, 2009 Share Posted January 22, 2009 $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. Quote Link to comment https://forums.phpfreaks.com/topic/141884-form-after-submit-variable-undefined/#findComment-742888 Share on other sites More sharing options...
.josh Posted January 22, 2009 Share Posted January 22, 2009 I don't really understand why you're trying to use GET variables when you have the same variables in hidden POST fields. QFT Quote Link to comment https://forums.phpfreaks.com/topic/141884-form-after-submit-variable-undefined/#findComment-742889 Share on other sites More sharing options...
tayhaithian Posted January 22, 2009 Author Share Posted January 22, 2009 done i got what its error . Below code in wrong row ~ $row=mysql_fetch_assoc($data); Quote Link to comment https://forums.phpfreaks.com/topic/141884-form-after-submit-variable-undefined/#findComment-742905 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.