How to insert data with php into database mysqli, not working completely

  database, mysql, php, sql

I’m trying to add input in my database, but unfortunately it doesn’t work. I checked everything within my knowledge. Maybe someone can help me out?
I tried it with fewer inputfields and it worked but I need a lot of information to add in my database.

Underneath is my code:

<?php 

if(isset($_POST['submit'])){

$product_title = $_POST['product_title'];
$product_width = $_POST['product_width'];
$product_size = $_POST['product_size'];
$product_height = $_POST['product_height'];
$product_si = $_POST['product_si'];
$product_li = $_POST['product_li'];
$product_cat = $_POST['product_cat'];
$cat = $_POST['cat'];
$manufacturer_id = $_POST['manufacturer'];
$product_price = $_POST['product_price'];
$product_keywords = $_POST['product_keywords'];
$product_desc = $_POST['product_desc'];
$product_sale = $_POST['product_sale'];
$product_label = $_POST['product_label'];

$product_img1 = $_FILES['product_img1']['name'];
$product_img2 = $_FILES['product_img2']['name'];
$product_img3 = $_FILES['product_img3']['name'];

$temp_name1 = $_FILES['product_img1']['tmp_name'];
$temp_name2 = $_FILES['product_img2']['tmp_name'];
$temp_name3 = $_FILES['product_img3']['tmp_name'];

move_uploaded_file($temp_name1,"product_images/$product_img1");
move_uploaded_file($temp_name2,"product_images/$product_img2");
move_uploaded_file($temp_name3,"product_images/$product_img3");

$insert_product = "insert into products (p_cat_id,cat_id,manufacturer_id,date,product_title,product_width,product_size,product_height,product_si,product_li,product_img1,product_img2,product_img3,product_price,product_keywords,product_desc,product_label,product_sale) values ('$product_cat','$cat','$manufacturer_id',NOW(),'$product_title','$product_width','$product_size','$product_height','$product_si','$product_li','$product_img1','$product_img2','$product_img3','$product_price','$product_keywords','$product_desc','$product_label','$product_sale')";

$run_product = mysqli_query($con,$insert_product);

if($run_product){
    
    echo "<script>alert('Product has been inserted sucessfully')</script>";
    echo "<script>window.open('index.php?view_products','_self')</script>";
    
}

}

?>


<?php } ?>

Source: Ask PHP

LEAVE A COMMENT