I want to add an array of hidden inputs to a database. Somehow an error occurs:
(index):6772 crbug/1173575, non-JS module files deprecated.
HTTP ERROR 500
The site is hosted. Changing browsers and similar methods do not help, the error is somewhere in the code
<?php
require_once '../vendor/connect.php';
$name = $_POST['name'];
$price = $_POST['price'];
$quantity = $_POST['quantity'];
$orders = array_map(
fn($name, $price, $quantity) => ['name' => $name, 'price' => $price, 'quantity' => $quantity],
$name,
$price,
$quantity
);
$sqlValues = [];
foreach ($orders as $order) {
$sqlValues[] = '('
. implode(', ', array_map(fn($val) => "'" . mysqli_real_escape_string($connect, $val) . "'", $order))
. ')';
}
$sql .= implode(', ', $sqlValues);
var_dump($sql);
$sql = 'insert into `zakaz` (`name`, `price`, `quantity`) values '($order['name'], $order['price'], $order['quantity'])';
?>
Data comes from
<input type="hidden" name="name[]" value="${name}">
<input class="js-cart-input-quantity" type="hidden" name="quantity[]" value="${quantity}">
<input class="js-cart-input-price" type="hidden" name="price[]" value="${price * quantity}">
May be need to connect to the database somehow differently? My connect.php:
<?php
$connect = mysqli_connect('localhost', 'a0634339_base', 'root', 'a0634339_base');
if (!$connect) {
die('Error connect to DataBase');
}
?>
My database
CREATE TABLE `zakaz` (
`name` varchar(255) DEFAULT NULL,
`price` varchar(255) DEFAULT NULL,
`quantity` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT;