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
50
51
52
53
54
55
|
<?php require("configure.php");
$pid = $_POST["pid"]; $catname = htmlspecialchars($_POST["catname"],ENT_QUOTES); $levelnum = $_POST["levelnum"];
$sql = "select max(catid) as maxid "; $sql .= "from prodcategory "; $result=mysql_query($sql); $row = mysql_fetch_array($result,MYSQL_ASSOC); $catid = $row{maxid}+1;
// Upload File if ($_FILES['catimage']['name'] <> '') { if (($_FILES["catimage"]["type"] == "image/bmp") || ($_FILES["catimage"]["type"] == "image/BMP") || ($_FILES["catimage"]["type"] == "image/gif") || ($_FILES["catimage"]["type"] == "image/GIF") || ($_FILES["catimage"]["type"] == "image/jpg") || ($_FILES["catimage"]["type"] == "image/JPG") || ($_FILES["catimage"]["type"] == "image/jpeg") || ($_FILES["catimage"]["type"] == "image/JPEG") || ($_FILES["catimage"]["type"] == "image/pjpeg") || ($_FILES["catimage"]["type"] == "image/PJEG") || ($_FILES["catimage"]["type"] == "image/png") || ($_FILES["catimage"]["type"] == "image/x-png") || ($_FILES["catimage"]["type"] == "image/PNG") || ($_FILES["catimage"]["type"] == "image/X-PNG")) { copy ($_FILES['catimage']['tmp_name'], "product/id_".$catid."_".$_FILES['catimage']['name']) or die ("Could not copy the file"); $catimage = "id_".$catid."_".$_FILES['catimage']['name']; } else { // upload error ?> <script language="javascript"> alert("Files must be BMP, JPEG, GIF, or PNG"); history.back(); </script> <?php exit; }
} else { $catimage = ""; }
$sql = "select max(catsort) as maxid "; $sql .= "from prodcategory where parentid=$pid "; $result=mysql_query($sql); $row = mysql_fetch_array($result,MYSQL_ASSOC); $catsort = $row{maxid}+1;
mysql_query("insert into prodcategory (catid, parentid, catname, catimage, catsort, levelnum) values ('$catid', '$pid', '$catname', '$catimage', '$catsort', '$levelnum')");
mysql_close($dbh);
header("Location: prodcat_index.php?pid=$pid&msg=Add Successful"); ?>
|