<?php
include('../includes/connect.php');
if(isset($_POST['insert_product'])){
$product_title=$_POST['product_title'];
$description=$_POST['description'];
$product_keywords=$_POST['product_keywords'];
$product_category=$_POST['product_category'];
$product_brands=$_POST['product_brands'];
$product_price=$_POST['product_price'];
$product_status='true';
//accessing images
$product_image1=$_FILES['product_image1']['name'];
$product_image2=$_FILES['product_image2']['name'];
$product_image3=$_FILES['product_image3']['name'];
//accessing image tmp name
$temp_image1=$_FILES['product_image1']['tmp_name'];
$temp_image2=$_FILES['product_image2']['tmp_name'];
$temp_image3=$_FILES['product_image3']['tmp_name'];
//checking empty condition
if($product_title=='' or $description=='' or $product_keywords=='' or $product_category=='' or $product_brands=='' or $product_price=='' or $product_image1=='' or $product_image2=='' or $product_image3==''){
echo "<script>alert('please fill all the available fields')</script>";
}
else{
//insert query
$insert_products="insert into products (product_title,product_description,product_keywords,category_id,brand_id,product_image1,product_image2,product_image3,product_price,date,status) values ('$product_title','$description','$product_keywords','$product_category','$product_brands','$product_image1','$product_image2','$product_image3','$product_price',NOW(),'$product_status')";
if($result_query){
echo "<script>alert('successfully inserted the products')</script>";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insert Product-Admin Dashboard</title>
<!-- bootstrap css link -->
<link href="https://c...content-available-to-author-only...r.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<!-- font awesome link -->
<link rel="stylesheet" href="https://c...content-available-to-author-only...e.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- css file -->
<link rel="stylesheet" href="style.css">
</head>
<body class="bg-light mt-3 w-50 m-auto">
<div class="contianer">
<h1 class="text-center">insert products</h1>
<!-- title -->
<form action="" method="post" enctype="multipart/from-data">
<div class="from-outline mb-4">
<label for="product_title" class="form-label text-center">Product title</label>
<input type="text" name="product_title" id="product_title" class="form control" placeholder="Enter product title" autocomplete="off" required="required">
</div>
<!-- description -->
<form action="" method="post" enctype="multipart/from-data">
<div class="from-outline mb-4">
<label for="description" class="form-label text-center">Product description</label>
<input type="text" name="description" id="description" class="form control" placeholder="Enter product description" autocomplete="off" required="required">
</div>