You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.3 KiB
75 lines
2.3 KiB
<?php
|
|
$id= "";
|
|
$accounttype= "";
|
|
$accountid= "";
|
|
$pwd= "";
|
|
$name= "";
|
|
$tel= "";
|
|
$address= "";
|
|
$email= "";
|
|
$lineid= "";
|
|
$wechatid= "";
|
|
$phone_call_help= "";
|
|
$chat_for_help= "";
|
|
$remote_help= "";
|
|
$repairerid= "";
|
|
$manager= "";
|
|
$creater= "";
|
|
$create_at= "";
|
|
|
|
|
|
|
|
$id_error = "";
|
|
$accounttype_error= "";
|
|
$accountid_error= "";
|
|
$pwd_error= "";
|
|
$name_error= "";
|
|
$tel_error= "";
|
|
$address_error= "";
|
|
$email_error= "";
|
|
$lineid_error= "";
|
|
$wechatid_error= "";
|
|
$phone_call_help_error= "";
|
|
$chat_for_help_error= "";
|
|
$remote_help_error= "";
|
|
$repairerid_error= "";
|
|
$manager_error= "";
|
|
$creater_error= "";
|
|
$create_at_error= "";
|
|
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
include "account-user-input.php";
|
|
|
|
$db_query = "INSERT INTO account(accounttype, accountid, pwd, name, tel, address, email, lineid, wechatid, phone_call_help, chat_for_help, remote_help, repairerid, manager, department_id, role_id, creater, create_at) VALUES ";
|
|
$db_query .= "('$accounttype', '$accountid','$pwd', '$name', '$tel', '$address', '$email', '$lineid', '$wechatid', '$phone_call_help', '$chat_for_help', '$remote_help', '$repairerid', '$manager', '$department_id', '$role_id', '$creater', '$create_at')";
|
|
$result = mysqli_query($link,$db_query);
|
|
|
|
// 新增權限
|
|
if (($accounttype == "B" || $accounttype == "E" || $accounttype == "M") && $department_id && $role_id) {
|
|
$db_query = "insert into account_auth (accountid, permission) ";
|
|
$db_query .= "select '$accountid', permission from department where department_id = '$department_id' and role_id = '$role_id'";
|
|
$res = mysqli_query($link, $db_query);
|
|
}
|
|
|
|
// mysqli_insert_id可以抓到第一筆的id
|
|
//$new_id= mysqli_insert_id ($link);
|
|
#echo "新增後的id為 {$id} ";
|
|
$affected = mysqli_affected_rows($link);
|
|
mysqli_close($link);
|
|
if ($affected > 0) {
|
|
// 如果有一筆以上代表有更新
|
|
echo "<script>";
|
|
echo "alert('新增成功');";
|
|
echo "location.href='account-index.php?function_name=account&".$token_link."';";
|
|
echo "</script>";
|
|
} elseif ($affected == 0) {
|
|
echo "<script>";
|
|
echo "alert('無新增資料');";
|
|
echo "location.href='account-index.php?function_name=account&".$token_link."';";
|
|
echo "</script>";
|
|
} else {
|
|
echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link);
|
|
}
|
|
}
|
|
?>
|