I can copy columns from one table to another but my problem is to insert a data in the column of new table from an input form in a single query
Here I'd like to add this $tom in the column along with "name and price" and this $tom is from another input form
<form method="post" enctype="multipart/form-data">
<input type="text" name="code" placeholder="Enter the Product Code" />
<button name="add_to_cart">Submit</button>
</form>
<?php
$db = mysqli_connect('localhost','root','','mainstock');
if(isset($_POST['add_to_cart']))
{
$tom = $_SESSION['cust'];
$code = $_POST['code'];
$query = "INSERT INTO sales (name,price,cust) SELECT name,price FROM tbl_product WHERE code = '$code' VALUES('{$tom}')";
$res = mysqli_query($db,$query);