################################# # 新增資料 # ################################# function op_insert() { global $mysqli; #資料過濾 #http://php.net/manual/en/mysqli.real-escape-string.php $_POST['title'] = $mysqli->real_escape_string($_POST['title']); $_POST['target'] = intval($_POST['target']); $_POST['enable'] = intval($_POST['enable']); $_POST['sort'] = intval($_POST['sort']); $_POST['url'] = $mysqli->real_escape_string($_POST['url']); $_POST['kind'] = $mysqli->real_escape_string($_POST['kind']); $sql = "insert into `creative_nav` (`title`, `target`, `enable`, `sort`,`url`,`kind`) VALUES ('{$_POST['title']}', '{$_POST['target']}', '{$_POST['enable']}', '{$_POST['sort']}', '{$_POST['url']}', '{$_POST['kind']}')"; $mysqli->query($sql) or die(printf("Error: %s " . $sql, $mysqli->sqlstate)); $sn = $mysqli->insert_id; //傳回insert 指令所產生之流水號 return $sn; } ```