How to send form data to two tables along with logged in user id as a variable for one of the tables

Viewed 37

I am trying to send form data to two different tables (orders and a list of orders) although, for one of the tables, the custID, I need to use the logged-in persons ID.

I have a login and session functionality coded (requiring email and password although customers have an auto inc id #) although dont know how to set customerID to the usersID etc.

inputs from HMTL FORM

orddate = $_POST['orddate'];    
$notes = $_POST['specialinstructions'];        
$itemID = $_POST['itemID'];        
$quant# = $_POST['quant#'];        

I need custID for the order table to that of logged in user

if ($error == 0) {
    $query = "INSERT INTO order (orddate,specialinstructions, * ) VALUES (?,?, *)";
    $query2 = "INSERT INTO ordertally (itemID,quant#) VALUE (?,?)";
     
     $stmt = mysqli_prepare($DBC,$query); 
     $stmt2 = mysqli_prepare($DBC,$query2); 
 
     
 mysqli_stmt_bind_param($stmt,'sss', $orddate,$specialinstructions,$custID*); 
 mysqli_stmt_bind_param($stmt2,'ss', $itemID,$quant#);       
1 Answers

I was able to achieve this by using the following code. thank you for your suggestions!

mysqli_stmt_bind_param($stmt,'iss', $_SESSION['userid'],
Related