27 lines
896 B
PHP
27 lines
896 B
PHP
<?php
|
|
include_once '_common.php';
|
|
if(!$_SESSION['user_id']) exit; // 로그인 되어있지 않으면 확인 불가
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") { // POST로 넘어온 값이 있다면
|
|
// 변수 선언
|
|
$date = trim($_POST["searchDate"]);
|
|
$worker = trim($_POST['worker']);
|
|
$author = trim($_POST['author']);
|
|
|
|
// update query
|
|
$query = "INSERT INTO {$fg['bakery_author_table']} (date, worker, author) ";
|
|
$query .= "VALUES('{$date}', '{$worker}', '{$author}') ";
|
|
// 이미 값이 있는 경우 업데이트함
|
|
$query .= "ON DUPLICATE KEY UPDATE worker = '{$worker}', author = '{$author}' ";
|
|
|
|
$result = sql_query($query);
|
|
|
|
if ($result) {
|
|
echo json_encode(array('success' => true));
|
|
} else {
|
|
echo json_encode(array('success' => false, 'message' => 'Database error'));
|
|
}
|
|
} else {
|
|
echo json_encode(array('success' => false, 'message' => 'Invalid request method'));
|
|
}
|