-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddItemController.php
More file actions
39 lines (28 loc) · 946 Bytes
/
Copy pathaddItemController.php
File metadata and controls
39 lines (28 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
include_once "./dbconnect.php";
if(isset($_POST['upload']))
{
$ProductName = $_POST['p_name'];
$desc= $_POST['p_desc'];
$price = $_POST['p_price'];
$category = $_POST['category'];
$name = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
$location="img/products/";
$image=$location.$name;
$target_dir="img/products/";
$finalImage=$target_dir.$name;
move_uploaded_file($temp,$finalImage);
$insert = mysqli_query($conn,"INSERT INTO products
(product_title,product_img1,product_price,product_desc,cat_id)
VALUES ('$ProductName','$image',$price,'$desc','$category')");
if(!$insert)
{
echo mysqli_error($conn);
}
else
{
echo "Records added successfully.";
}
}
?>