I got a problem in show the input data from one page to another page
I try to transfer it when we click the submit button
this is my code which is I try to transfer the data
function cart() {
$total = 0;
foreach($_SESSION as $name => $value) {
if ($value>0) {
if (substr($name, 0, 5) == 'cart_'){
$id = substr($name, 5, (strlen($name)-5));
$get = mysql_query('SELECT id, name, price FROM menu WHERE id=' .mysql_real_escape_string((int)$id));
while ($get_row = mysql_fetch_assoc($get)){
$sub = $get_row['price'] * $value;
echo $get_row['name'].' x '.$value.' @ $'.number_format($get_row['price'], 2).' = $'.number_format($sub, 2).' <a href="cart.php?remove='.$id.'">[-]</a> <a href="cart.php?add='.$id.'">[+]</a> <a href="cart.php?delete='.$id.'">[Delete]</a><br />' ;
}
}
$total += $sub;
}
}
if ($total == 0){
echo "Your Cart Is Empty";
}
else {
echo "<p>Total : $".number_format($total, 2).'</p>';
<p>
<form action="bill.php" method="post">
<?php paypal_items(); ?>
<input type="submit" value="submit" />
</form>
</p>
}
}
I try to show this line to another page
echo $get_row['name'].' x '.$value.' @ $'.number_format($get_row['price'], 2).' = $'.number_format($sub, 2).' <a href="cart.php?remove='.$id.'">[-]</a> <a href="cart.php?add='.$id.'">[+]</a> <a href="cart.php?delete='.$id.'">[Delete]</a><br />' ;
And I just try this code and I got error
bill.php
<?php
echo $get_row['name'].' x '.$value.' @ $'.number_format($get_row['price'], 2).' = $'.number_format($sub, 2);
?>
the error
Notice: Undefined variable: get_row in C:\xampp\htdocs\shopping\bill.php on line 2
Notice: Undefined variable: value in C:\xampp\htdocs\shopping\bill.php on line 2
Notice: Undefined variable: get_row in C:\xampp\htdocs\shopping\bill.php on line 2
Notice: Undefined variable: sub in C:\xampp\htdocs\shopping\bill.php on line 2
x @ $0.00 = $0.00
anyone know how to do it???
I’m just a newbie in this field…
thanks
Add
session_start();to the first line of your first php file. then addbefore echo. Then in your second php file, again add
session_start();to the first line and you may echo value like;