How to send the session data in one page to another? here's my code because I am going to bill out all of the orders and Name and ID of the current user logged int ,
the PHP code
<?php
session_start();
include("Connection.php");
if (isset($_POST['submit'])) {
$name = $_POST['customerName'];
mysql_query("INSERT INTO `starbucks`.`orders` (
`ID` ,
`NAME` ,
`TOTAL_PRICE` ,
`TOTAL_ITEMS` ,
`TIME`
)
VALUES (
'' , '$name', '', '',NOW())");
$_SESSION['user'] = $name;
}
$name = $_SESSION['user'];
$dTime = time();
$myValue = isset($_REQUEST['dValue']) ?$_REQUEST['dValue'] : '';
echo "The time is: {$dTime}<br/>
The choice is {$myValue} ";
$sql = "Select * from product where NAME = '{$myValue}'";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
$price = $row['PRICE'];
$id = $row['ID'];
$sql3 = "SELECT ID from orders where NAME ='$name'";
$result3=mysql_query($sql3);
while ($row1 = mysql_fetch_assoc($result3)){
$cID = $row1['ID'];
}
$sql2 ="INSERT INTO order_details(ID, ORDER_ID,PRODUCT_ID,QTY)
VALUES ('', '$cID', '$id','1')";
$result2 = mysql_query($sql2);
}
?>
Here's the code for the Form to go to the billout page
<FORM METHOD="LINK" ACTION="Receipt.php" >
<INPUT TYPE="submit" VALUE="Billout">
The thing I want to happen is that once the user is done click the orders, the ID, The NAME, will be sent to the other page, where the user will see his orders and his total amount to be payed
the other php page
This is where he will see his orders (the current User)
<?php
include 'Connection.php';
session_start();
$sql = "SELECT
*
FROM
orders
JOIN
order_details
ON
orders.ID =order_details.ORDER_ID";
$result=mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['ID']."-".$row['NAME']."<br>".$row['TIME'];
echo "Product ID".$row['PRODUCT_ID']."-".$row['QTY'];
}
?>
I am new on php go easy on me, this is just for our project please help all I want to transfer is the session name variable or the Customer name