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
56
57
58
59
60
61
|
<?php require_once ("check_login.php");
//checking data $message = "";
if (empty($_POST["code"])) { $message .= "請輸入產品編號。\\n\\n"; }
foreach ($arraylangcode as $langcode => $langname) { if (empty($_POST["name_".$langcode])) { $message .= "請輸入產品名稱[".$langname."]。\\n\\n"; } }
if (empty($_POST["price"])) { $message .= "請輸入價格。\\n\\n"; } else { if (!is_numeric($_POST["price"]) || $_POST["price"] < 0) { $message .= "價格應是正數數字。\\n\\n"; } }
if (!empty($message)) { //echo "<script>alert('" . $message . "'); history.back();</script>"; echo "<script>alert('" . $message . "');</script>"; exit; }
if(isset($_POST["show_frontend"]) && $_POST["show_frontend"] == 1){ $show_frontend = 1; }else{ $show_frontend = 0; }
/*$sql = "select max(sort) as maxsort from product"; $row = bind_pdo($sql, NULL, "selectone"); $sort = $row{"maxsort"} + 1;*/
//update all product sort $sql = "update product set sort = sort + 1 where deleted = ?"; $parameters = array("0"); bind_pdo($sql, $parameters);
$sql = "insert into product set show_frontend=?, price=?, code=?, sort=?, createdate=?, createby=?, lastupdate=?, lastupby=?, "; $parameters = array($show_frontend, $_POST["price"], $_POST["code"], 1, $nowdate, $_SESSION['cmsloginid'], $nowdate, $_SESSION['cmsloginid']);
foreach ($arraylangcode as $langcode => $langname) { $sql .= "name_" . $langcode . "=?, desc_" . $langcode . "=?, "; $parameters[] = $_POST["name_" . $langcode]; $parameters[] = $_POST["desc_" . $langcode]; }
$sql = substr_replace($sql, "", -2); bind_pdo($sql, $parameters);
$id = $dbh->lastInsertId();
header("Location: product_image_addform.php?productid=$id");
|