If someone can help me to solve this issue? when I submit form its come with HTTP500 Error, no record insert into SQL database,
if someone can help ?
Here is a database structure
Coding
include(’…/connection.php’);
if (isset($_GET['action']) && $_GET['action'] == 'add-product' && isset($_POST['add-product-btn'])) {
if (($_FILES['image']['name']!="")){
$target_dir = "upload/";
$file = $_FILES['image']['name'];
$path = pathinfo($file);
$filename = getRandomValue().'-'.$path['filename'];
$ext = $path['extension'];
$temp_name = $_FILES['image']['tmp_name'];
$path_filename_ext = $target_dir.$filename.".".$ext;
move_uploaded_file($temp_name,$path_filename_ext);
$data = [];
array_push($data, $_POST['product-name']);
array_push($data, $_POST['video-link']);
array_push($data, $filename.'.'.$ext);
array_push($data, $_POST['product-description']);
array_push($data, json_encode($_POST['product-category']));
array_push($data, $_POST['short-description']);
array_push($data, json_encode($_POST['product_process']));
$query = mysqli_query($con, “INSERT INTO products
( product_name
, product_video_link
, product_image
, product_description
, product_category
, short_description
, product_process
) VALUES (’$data[0]’, ‘$data[1]’, ‘$data[2]’, ‘$data[3]’, ‘$data[4]’, ‘$data[5]’, ‘$data[6]’)”);
if ($query > 0) {
$_SESSION['product_success'] = "Product addedd Successfully!";
header('location: products.php');
}else{
$_SESSION['product_error'] = "Product couldn't be added. Please try later...";
header('location: add-product.php');