-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddproduct.php
49 lines (39 loc) · 1.51 KB
/
addproduct.php
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
40
41
42
43
44
45
46
47
48
49
<?php
include ("conn.php");
mysqli_select_db($conn,"bowwow");
$proName = $_POST["proname"];
$prodesc = $_POST["prodesc"];
$prosele = $_POST["prosele"];
$cate = $_POST["catesele"];
$qty = $_POST["qty"];
$price = $_POST["price"];
$status = $_POST["status"];
$img = $_FILES["up"];
$temp = $img['tmp_name'];
//if (!isset($img)){
// $err = $_FILES["up"]["error"];
#echo "<script>alert('$err');location.href='".$_SERVER["HTTP_REFERER"]."';</script>";
//}
//echo $catesele;
if ($proName == ""){
echo "<script>alert('Warning:Name cannot be empty!');location.href='".$_SERVER["HTTP_REFERER"]."';</script>";
}else
{
$add = "INSERT INTO product (name, description, is_hot, cate_id, price, status, stock_qty) VALUES ('$proName','$prodesc', '$prosele', '$cate','$price','$status','$qty')";
mysqli_query($conn, $add);
$id = mysqli_insert_id($conn);
$path = "category_img/".$id.".jpg";
if (isset($img)){
$imgname = $id.".jpg";
$path = "./images/product_img/".$imgname;
move_uploaded_file($temp, $path);
$addimg = "UPDATE product SET image_path ='$imgname' WHERE id = {$id}";
mysqli_query($conn, $addimg);
}
echo "<script>alert('Add product Successfully');location.href='product.php';</script>";
}
//$userEmail = $_POST["email"];
//$sql = "INSERT INTO test (id,email) VALUES ('$userName','$userEmail')";
//mysqli_query($conn, $sql);
//echo "<script>alert('success');location.href='".$_SERVER["HTTP_REFERER"]."';</script>";
?>