<?
// 기본 설정 로딩
require_once 'config.php';
require_once 'function.php';
require_once 'lib.php';

if ($_POST[mkread]) {
    $query = "UPDATE commentdb SET read_check='$_POST[readname],$_POST[name]' WHERE num='$_POST[num]'";
    @mysql_query($query, $db_connect) or die(mysql_error() . $db_q_error);

} elseif ($_POST[num]) {
//    echo "발신자를 찾을 수 없습니다";
    $query = "UPDATE commentdb SET read_check='1' WHERE num='$_POST[num]'";
    @mysql_query($query, $db_connect) or die(mysql_error() . $db_q_error);

} else {
    $query = "INSERT INTO commentDB (ID, comment_case, content, receiver, write_date, write_time, read_check) values('$_POST[name]', '$_POST[comment_case]', '$_POST[content]', '$_POST[receiver]', curdate(), curtime(), 0)";
//$query="UPDATE comment.db SET comment_case='$_POST[comment_case]',ID='$_POST[name]',content='$_POST[content]',receiver='$_POST[receiver]' WHERE  Client_Code='$_POST[client_code]'";
    @mysql_query($query, $db_connect) or die(mysql_error() . $db_q_error);
}

//DB닫기
mysql_close($db_connect);
$setup_dir = "http://" . $_SERVER['HTTP_HOST'] . ":6752";
if ($_POST[page] != 'comment') {
    echo "<meta http-equiv=\"refresh\" content=\"0;URL='" . $setup_dir . "/DefaultPage.cli'\" />";
} else {
    echo "<meta http-equiv=\"refresh\" content=\"0;URL='" . $setup_dir . "/commentList.cm#receive'\" />";
}
