게시물 댓글 한 아이디당 하나만 달 수 있게 하는 방법
본문
https://sir.kr/g5_skin/57635?sfl=wr_subject&stx=%EB%B3%84%EC%A0%90
설국열차님의 코드를 이용하여 댓글에 별점 기능을 추가하였습니다.
한 아이디의 무분별한 평점 테러를 막기위해 1게시물당 1아이디당 1개의 댓글만 달게 해주고싶은데
커뮤니티를 아무리 뒤져도 속시원하게 해결이 되지 않습니다.
이용중인 게시판에 write_comment_update.head.skin.php 파일을 만들었는데 select문이 잘못된건지 한번 봐주실 수 있을까요?
<?php
if (!defined('_GNUBOARD_')) exit;
if ($w == 'c' && $mb_id)
{
$sql = "SELECT wr_id from $write_table where wr_parent = '$wr_id' and wr_is_comment = 1 and mb_id = '$mb_id' ";
$cm = sql_fetch($sql);
if($cm['wr_id']) {
alert("댓글은 게시물당 1번만 가능합니다.");
}
sql_query($sql, true);
}
?>
답변 1
$member['mb_id'] 를 써야 될 것 같습니다.
<?php
if (!defined('_GNUBOARD_')) exit;
if ($w == 'c' && $member['mb_id'])
{
$sql = "SELECT wr_id from {$write_table} where wr_parent = '{$wr_id}' and wr_is_comment = 1 and mb_id = '{$member['mb_id']}' ";
$cm = sql_fetch($sql);
if($cm['wr_id']) {
alert("댓글은 게시물당 1번만 가능합니다.");
}
sql_query($sql, true);
}
?>
답변을 작성하시기 전에 로그인 해주세요.