I wanted to add the $item_id into the ‘bid’ table after clicking on the button.
But the $item_id from the $_GET cannot be passed into the $_POST function.
Is it incorrect to call a variable like this?
Thank you in advance for your help!
<?php
include ('config/dbfunctions.php');
include ("helpers/validateBid.php");
$user_id = "";
$item_id = "";
$table= 'bid';
$allBids = selectAll($table);
$items = selectAll('item');
if (isset($_GET['item_id'])) {
$itemInfoPost = selectOne('item', ['item_id' => $_GET['item_id']]);
$item_id = $itemInfoPost['item_id'];
}
if(isset($_POST['bid-btn'])){
unset($_POST['bid-btn']);
$_POST['user_id'] = $_SESSION['user_id'];
$_POST['item_id'] = $item_id; //$item_id cannot be called
$bid_id = create($table, $_POST);
header('location: itemInfo.php?item_id='."$item_id");
}