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

Is this you wanted to do?

page1.php

session_start();
$_SESSION["var"] = "foo";

page2.php

session_start();
echo $_SESSION["var"];

Is this you wanted to do?

page1.php

session_start();
$_SESSION["var"] = "foo";

page2.php

session_start();
echo $_SESSION["var"];

okay all done, another question how do I align the results in this table?

<?php
include 'Connection.php';	
session_start(); 

   if (isset($_POST['submit'])) {
    $name = $_POST['customerName'];
}
$name = $_SESSION['user'];

$sql = "SELECT 
    * 
FROM 
    orders
JOIN 
    order_details 
ON 
    orders.ID =order_details.ORDER_ID
	WHERE NAME = '$name'";
	
	

$result=mysql_query($sql) or die(mysql_error());
echo "<table border=1>";
echo "<tr><th>NAME</th> <th>ORDER DETAILS</th><th>TIME</th> </tr>";
echo "</table>";
$row = mysql_fetch_array($result);
echo $row['NAME']."".$row['ORDER_ID'];


?>
$result=mysql_query($sql) or die(mysql_error());
echo "<table border=1>";
echo "<thead><th>NAME</th> <th>ORDER DETAILS</th><th>TIME</th> </thead>";
while($row = mysql_fetch_array($result))
{
   print '<tr><td>'.$row['NAME'].'</td><td>'.$row['ORDER_ID'].'</td><td>'.$TIME_VARIABLE.'</td></tr>';
}
echo "</table>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.