본문 바로가기
Programming

[PHP 강좌] 47. 설치형 게시판 10 - 답글달기, 글수정, 글삭제

by Mizix 2010. 2. 11.
반응형
드디어 설치형 게시판의 마지막 시간입니다.

이번시간에는 답글달기, 글수정, 글삭제에 대해서 배워보도록 하겠습니다.

특별한 부분만 설명을 하고 나머지는 주석을 통해 이해하실수 있을것입니다.

본 게시판은 http://handsome.hosting.paran.com/i_board/ 에서 확인하실수 있습니다.

답글 부분은 관계형 게시판 만들기 부분에서 설명해 드렸습니다.(http://handsome.pe.kr/70)

답글달기 부분입니다.
<?
// 1. 공통 인클루드 파일
include ("./head.php");

// 2. 게시판 코드 검사
$bc_code = $_GET[bc_code];
if($bc_code){
    // 3. 게시판 코드가 있으면 게시판 설정 불러오기
    $b_config_sql = "select * from ".$_cfg['config_table']." where bc_code = '".$bc_code."'";
    $board_config = sql_fetch($b_config_sql);
}else{
    alert("게시판 코드가 없습니다.");
}

// 4. 존재하는 게시판인지 확인
if(!$board_config[bc_idx]){
    alert("존재 하지 않는 게시판입니다.");
}

// 5. 게시판 권한 체크
if($_SESSION[user_level]){
    $u_level = $_SESSION[user_level];
}else{
    $u_level = 0;
}

if($u_level < $board_config[bc_reply_level]){
    alert("권한이 없습니다.", "./index.php");
}

// 6. 글정보 가져오기
$b_idx = $_GET[b_idx];
$sql = "select * from ".$_cfg['board_table']." where bc_code = '".$bc_code."' and b_idx = '".$b_idx."'";
$data = sql_fetch($sql);

// 7. 해당 글이 있는지 와 비밀글이면 비밀번호 입력여부 체크체크
if(!$data[b_idx]){
    alert("존재 하지 않는 글입니다.");
}

// 8. 댓글이 가능한지 검사
// 8-1. 이 글의 단계가 몇단계 인지 검사후 3단계면 댓글 불가
if(strlen($data[b_reply]) == 3){
    alert("더이상 댓글을 쓸수가 없습니다.");
}

// 8-2 이글에 달린 댓글의 마지막 댓글이 몇번째인지 검사

$sql2 = "select * from ".$_cfg['board_table']." where bc_code = '".$bc_code."' and b_num = '".$data[b_num]."' and b_reply like '".$data[b_reply]."%' order by b_reply desc limit 1";
$result2 = sql_query($sql2);
$data2 = mysql_fetch_array($result2);

if(substr($data2[b_reply], strlen($data[b_reply]), 1) == "Z"){
    alert("더이상 댓글을 쓸수가 없습니다.");
}

// 9. 게시판 상단 이미지 출력
$dir = "./data/board_config";
$head_file = $dir."/".$board_config[bc_idx]."_head";

if($board_config[bc_head_file] && file_exists($head_file)){
?>
<br/>
<img src="<?=$head_file?>">
<?
}

// 10. 게시판 상단 내용 출력
if($board_config[bc_head]){
?>
<br/>
<table border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td align="left" valign="middle" style="font-zise:15px;"><?=$board_config[bc_head]?></td>
    </tr>
</table>
<?
}

// 11. 입력 HTML 출력
?>
<br/>
<table style="width:1000px;height:50px;border:5px #CCCCCC solid;">
    <tr>
        <td align="center" valign="middle" style="font-zise:15px;font-weight:bold;">답글쓰기</td>
    </tr>
</table>
<br/>
<form name="bWriteForm" method="post" enctype="multipart/form-data" action="./board_reply_save.php" style="margin:0px;">
<input type="hidden" name="bc_code" value="<?=$bc_code?>">
<input type="hidden" name="b_idx" value="<?=$b_idx?>">
<input type="hidden" name="page" value="<?=$_GET[page]?>">
<table style="width:1000px;height:50px;border:0px;">
    <tr>
        <td align="center" valign="middle" style="width:200px;height:50px;background-color:#CCCCCC;">글제목</td& gt;
        <td align="left" valign="middle" style="width:800px;height:50px;"><input type="text" name="b_title" style="width:780px;"></td>
    </tr>
    <?
    // 12.로그인 한 상태가 아니면 이름을 쓰고 로그인 한 상태면 hidden 으로 넘김
    if(!$_SESSION[user_idx]){
    ?>
    <tr>
        <td align="center" valign="middle" style="width:200px;height:50px;background-color:#CCCCCC;">작성자명< /td>
        <td align="left" valign="middle" style="width:800px;height:50px;"><input type="text" name="m_name" style="width:780px;"></td>
    </tr>
    <?
    }else{
    ?>
    <input type="hidden" name="m_name" value="<?=$_SESSION[user_name]?>">
    <?
    }

    // 13. 비밀글을 사용하면 비밀글 체크 여부와 비밀번호 입력받기
    if($board_config[bc_use_secret]){
    ?>
    <tr>
        <td align="center" valign="middle" style="width:200px;height:50px;background-color:#CCCCCC;">비밀글 여부</td>
        <td align="left" valign="middle" style="width:800px;height:50px;"><input type="checkbox" name="b_is_secret" value="1"> 비밀글이면 체크</td>
    </tr>
    <tr>
        <td align="center" valign="middle" style="width:200px;height:50px;background-color:#CCCCCC;">비밀번호< /td>
        <td align="left" valign="middle" style="width:800px;height:50px;"><input type="text" name="b_pass" style="width:100px;"></td>
    </tr>
    <?
    }

    // 14. 파일 업로드를 사용하면 파일 입력
    if($board_config[bc_use_file]){
    ?>
    <tr>
        <td align="center" valign="middle" style="width:200px;height:50px;background-color:#CCCCCC;">첨부파일< /td>
        <td align="left" valign="middle" style="width:800px;height:50px;"><input type="file" name="b_file" ></td>
    </tr>
    <?
    }
    ?>
    <tr>
        <td align="center" valign="middle" style="width:200px;height:200px;background-color:#CCCCCC;">글내용< /td>
        <td align="left" valign="middle" style="width:800px;height:200px;">
        <textarea name="b_contents" style="width:800px;height:200px;"></textarea>
        </td>
    </tr>
    <!-- 15. 글쓰기 버튼 클릭시 입력필드 검사 함수 write_save 실행 -->
    <tr>
        <td align="center" valign="middle" colspan="2"><input type="button" value=" 글쓰기 " onClick="write_save();">&nbsp;&nbsp;&nbsp;<input type="button" value=" 뒤로가기 " onClick="history.back();"></td>
    </tr>
</table>
</form>
<script>
// 16.입력필드 검사함수
function write_save()
{
    // 17.form 을 f 에 지정
    var f = document.bWriteForm;

    // 18.입력폼 검사

    if(f.b_title.value == ""){
        alert("글제목을 입력해 주세요.");
        return false;
    }

    <?
    // 19. 비밀글을 사용하면 비밀글 체크 여부와 비밀번호 입력 체크
    if($board_config[bc_use_secret]){
    ?>
    if(f.b_is_secret.checked == true && f.b_pass.value == ""){
        alert("비밀번호를 입력해 주세요.");
        return false;
    }
    <?
    }
    ?>
   
    if(f.b_contents.value == ""){
        alert("글내용을 입력해 주세요.");
        return false;
    }

    // 20.검사가 성공이면 form 을 submit 한다
    f.submit();

}
</script>

<?
// 21. 게시판 하단 내용 출력
if($board_config[bc_tail]){
?>
<br/>
<table border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td align="left" valign="middle" style="font-zise:15px;"><?=$board_config[bc_tail]?></td>
    </tr>
</table>
<?
}

// 22. 게시판 하단 이미지 출력
$dir = "./data/board_config";
$tail_file = $dir."/".$board_config[bc_idx]."_tail";

if($board_config[bc_tail_file] && file_exists($tail_file)){
?>
<br/>
<img src="<?=$tail_file?>">
<?
}
?>
[board_reply.php 소스]

답글 저장 부분입니다.
<?
// 1. 공통 인클루드 파일
include ("./head.php");

// 2. 게시판 코드 검사
$bc_code = $_POST[bc_code];
if($bc_code){
    // 3. 게시판 코드가 있으면 게시판 설정 불러오기
    $b_config_sql = "select * from ".$_cfg['config_table']." where bc_code = '".$bc_code."'";
    $board_config = sql_fetch($b_config_sql);
}else{
    alert("게시판 코드가 없습니다.");
}

// 4. 존재하는 게시판인지 확인
if(!$board_config[bc_idx]){
    alert("존재 하지 않는 게시판입니다.");
}

// 5. 게시판 권한 체크
if($_SESSION[user_level]){
    $u_level = $_SESSION[user_level];
}else{
    $u_level = 0;
}

if($u_level < $board_config[bc_reply_level]){
    alert("권한이 없습니다.", "./index.php");
}

// 6. 부모글정보 가져오기
$b_idx = $_POST[b_idx];
$sql = "select * from ".$_cfg['board_table']." where bc_code = '".$bc_code."' and b_idx = '".$b_idx."'";
$data = sql_fetch($sql);

// 7. 해당 글이 있는지 와 비밀글이면 비밀번호 입력여부 체크체크
if(!$data[b_idx]){
    alert("존재 하지 않는 글입니다.");
}

// 8. 댓글이 가능한지 검사
// 8-1. 부모글의 단계가 몇단계 인지 검사후 3단계면 댓글 불가
if(strlen($data[b_reply]) == 3){
    alert("더이상 댓글을 쓸수가 없습니다.");
}

// 8-2 부모글에 달린 댓글의 마지막 댓글이 몇번째인지 검사

$sql2 = "select * from ".$_cfg['board_table']." where bc_code = '".$bc_code."' and b_num = '".$data[b_num]."' and b_reply like '".$data[b_reply]."%' order by b_reply desc limit 1";
$result2 = sql_query($sql2);
$data2 = mysql_fetch_array($result2);

$last_reply_char = substr($data2[b_reply], strlen($data[b_reply]), 1);
if($last_reply_char == "Z"){
    alert("더이상 댓글을 쓸수가 없습니다.");
}

// 9. 넘어온 변수 검사
if(trim($_POST[b_title]) == ""){
    alert("글제목을 입력해 주세요.");
}

if(trim($_POST[b_contents]) == ""){
    alert("글내용을 입력해 주세요.");
}

if($board_config[bc_use_secret] && $_POST[b_is_secret] == 1 && trim($_POST[b_pass]) == ""){
    alert("비밀번호를 입력해 주세요.");
}

// 10. b_num 과 b_reply 만들기
$b_num = $data[b_num];
if($last_reply_char){
    $b_reply = $data[b_reply].chr(ord($last_reply_char) + 1);
}else{
    $b_reply = $data[b_reply]."A";
}

// 11. 파일 변수 만들기
if($_FILES[b_file][tmp_name]){
    $b_filename = $_FILES[b_file][name];
    $b_filesize = $_FILES[b_file][size];
}else{
    $b_filename = "";
    $b_filesize = 0;
}

// 12. 글저장
$sql = "insert into ".$_cfg['board_table']." set bc_code = '".$bc_code."', b_num = '".$b_num."', b_reply = '".$b_reply."', m_id = '".$_SESSION[user_id]."', m_name = '".addslashes(htmlspecialchars($_POST[m_name]))."', b_title = '".addslashes(htmlspecialchars($_POST[b_title]))."', b_contents = '".addslashes(htmlspecialchars($_POST[b_contents]))."', b_is_secret = '".$_POST[b_is_secret]."', b_pass = '".$_POST[b_pass]."', b_filename = '".$b_filename."', b_filesize = '".$b_filesize."', b_regdate = now()";
sql_query($sql);

// 13. 저장된 글번호 찾기
$b_idx = mysql_insert_id();


// 14. 파일저장
$dir = "./data";
$b_file = $dir."/".$b_idx;

if($_FILES[b_file][tmp_name] && $b_filename){
    if(file_exists($b_file)){
        @unlink($b_file);
    }
    move_uploaded_file($_FILES[b_file][tmp_name], $b_file);
    chmod($b_file, 0666);

}

// 15. 글목록 페이지로 보내기
alert("글이 저장 되었습니다.", "./board_list.php?bc_code=".$bc_code."&page=".$_POST[page]);
?>
[board_reply_save.php 소스]

글수정 부분입니다.
<?
// 1. 공통 인클루드 파일
include ("./head.php");

// 2. 게시판 코드 검사
$bc_code = $_GET[bc_code];
if($bc_code){
    // 3. 게시판 코드가 있으면 게시판 설정 불러오기
    $b_config_sql = "select * from ".$_cfg['config_table']." where bc_code = '".$bc_code."'";
    $board_config = sql_fetch($b_config_sql);
}else{
    alert("게시판 코드가 없습니다.");
}

// 4. 존재하는 게시판인지 확인
if(!$board_config[bc_idx]){
    alert("존재 하지 않는 게시판입니다.");
}

// 5. 게시판 권한 체크
if($_SESSION[user_level]){
    $u_level = $_SESSION[user_level];
}else{
    $u_level = 0;
}

// 3. 글 데이터 불러오기
$b_idx = $_GET[b_idx];
$sql = "select * from ".$_cfg['board_table']." where bc_code = '".$bc_code."' and b_idx = '".$b_idx."'";
$data = sql_fetch($sql);

// 4. 글이 없으면 메세지 출력후 되돌리기
if(!$data[b_idx]){
    alert("존재하지 않는 글입니다.");
}

// 5. 본인의 글이 아니면 메세지 출력후 되돌리기
if($data[m_id] != $_SESSION[user_id] && $u_level != 9){
    alert("본인의 글이 아닙니다.");
}

// 6. 게시판 상단 이미지 출력
$dir = "./data/board_config";
$head_file = $dir."/".$board_config[bc_idx]."_head";

if($board_config[bc_head_file] && file_exists($head_file)){
?>
<br/>
<img src="<?=$head_file?>">
<?
}

// 7. 게시판 상단 내용 출력
if($board_config[bc_head]){
?>
<br/>
<table border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td align="left" valign="middle" style="font-zise:15px;"><?=$board_config[bc_head]?></td>
    </tr>
</table>
<?
}

// 8. 입력 HTML 출력
?>
<br/>
<table style="width:1000px;height:50px;border:5px #CCCCCC solid;">
    <tr>
        <td align="center" valign="middle" style="font-zise:15px;font-weight:bold;">글수정</td>
    </tr>
</table>
<br/>
<form name="bWriteForm" method="post" enctype="multipart/form-data" action="./board_modify_save.php" style="margin:0px;">
<input type="hidden" name="bc_code" value="<?=$bc_code?>">
<input type="hidden" name="b_idx" value="<?=$b_idx?>">
<input type="hidden" name="page" value="<?=$_GET[page]?>">
<table style="width:1000px;height:50px;border:0px;">
    <tr>
        <td align="center" valign="middle" style="width:200px;height:50px;background-color:#CCCCCC;">글제목</td& gt;
        <td align="left" valign="middle" style="width:800px;height:50px;"><input type="text" name="b_title" style="width:780px;" value="<?=$data[b_title]?>"></td>
    </tr>

    <?
    // 10. 비밀글을 사용하면 비밀글 체크 여부와 비밀번호 입력받기
    if($board_config[bc_use_secret]){
    ?>
    <tr>
        <td align="center" valign="middle" style="width:200px;height:50px;background-color:#CCCCCC;">비밀글 여부</td>
        <td align="left" valign="middle" style="width:800px;height:50px;"><input type="checkbox" name="b_is_secret" value="1" <?if($data[b_is_secret] == 1)echo "checked";?>> 비밀글이면 체크</td>
    </tr>
    <tr>
        <td align="center" valign="middle" style="width:200px;height:50px;background-color:#CCCCCC;">비밀번호< /td>
        <td align="left" valign="middle" style="width:800px;height:50px;"><input type="text" name="b_pass" style="width:100px;"  value="<?=$data[b_pass]?>"></td>
    </tr>
    <?
    }

    // 11. 파일 업로드를 사용하면 파일 입력
    if($board_config[bc_use_file]){
    ?>
    <tr>
        <td align="center" valign="middle" style="width:200px;height:50px;background-color:#CCCCCC;">첨부파일< /td>
        <td align="left" valign="middle" style="width:800px;height:50px;">
        <?
        // 11-1 파일이 있으면
        if($data[b_filename]){
        ?>
        <a href="./download.php?bc_code=<?=$bc_code?>&b_idx=<?=$b_idx?>"><?=$data[b_filename]?></a> <input type="checkbox" name="b_file_del" value="1"> 삭제<br>
        <?}?>
        <input type="file" name="b_file" >
        </td>
    </tr>
    <?
    }
    ?>
    <tr>
        <td align="center" valign="middle" style="width:200px;height:200px;background-color:#CCCCCC;">글내용< /td>
        <td align="left" valign="middle" style="width:800px;height:200px;">
        <textarea name="b_contents" style="width:800px;height:200px;"><?=$data[b_contents]?></textarea>
        </td>
    </tr>
    <!-- 12. 수정하기 버튼 클릭시 입력필드 검사 함수 write_save 실행 -->
    <tr>
        <td align="center" valign="middle" colspan="2"><input type="button" value=" 수정하기 " onClick="write_save();">&nbsp;&nbsp;&nbsp;<input type="button" value=" 뒤로가기 " onClick="history.back();"></td>
    </tr>
</table>
</form>
<script>
// 13.입력필드 검사함수
function write_save()
{
    // 14.form 을 f 에 지정
    var f = document.bWriteForm;

    // 15.입력폼 검사

    if(f.b_title.value == ""){
        alert("글제목을 입력해 주세요.");
        return false;
    }

    <?
    // 16. 비밀글을 사용하면 비밀글 체크 여부와 비밀번호 입력 체크
    if($board_config[bc_use_secret]){
    ?>
    if(f.b_is_secret.checked == true && f.b_pass.value == ""){
        alert("비밀번호를 입력해 주세요.");
        return false;
    }
    <?
    }
    ?>
   
    if(f.b_contents.value == ""){
        alert("글내용을 입력해 주세요.");
        return false;
    }

    // 17.검사가 성공이면 form 을 submit 한다
    f.submit();

}
</script>

<?
// 18. 게시판 하단 내용 출력
if($board_config[bc_tail]){
?>
<br/>
<table border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td align="left" valign="middle" style="font-zise:15px;"><?=$board_config[bc_tail]?></td>
    </tr>
</table>
<?
}

// 19. 게시판 하단 이미지 출력
$dir = "./data/board_config";
$tail_file = $dir."/".$board_config[bc_idx]."_tail";

if($board_config[bc_tail_file] && file_exists($tail_file)){
?>
<br/>
<img src="<?=$tail_file?>">
<?
}
?>
[board_modify.php 소스]

글수정 저장 부분입니다.
<?
// 1. 공통 인클루드 파일
include ("./head.php");

// 2. 게시판 코드 검사
$bc_code = $_POST[bc_code];
if($bc_code){
    // 3. 게시판 코드가 있으면 게시판 설정 불러오기
    $b_config_sql = "select * from ".$_cfg['config_table']." where bc_code = '".$bc_code."'";
    $board_config = sql_fetch($b_config_sql);
}else{
    alert("게시판 코드가 없습니다.");
}

// 4. 존재하는 게시판인지 확인
if(!$board_config[bc_idx]){
    alert("존재 하지 않는 게시판입니다.");
}

// 5. 게시판 권한 체크
if($_SESSION[user_level]){
    $u_level = $_SESSION[user_level];
}else{
    $u_level = 0;
}

// 3. 글 데이터 불러오기
$b_idx = $_POST[b_idx];
$sql = "select * from ".$_cfg['board_table']." where bc_code = '".$bc_code."' and b_idx = '".$b_idx."'";
$data = sql_fetch($sql);

// 4. 글이 없으면 메세지 출력후 되돌리기
if(!$data[b_idx]){
    alert("존재하지 않는 글입니다.");
}

// 5. 본인의 글이 아니면 메세지 출력후 되돌리기
if($data[m_id] != $_SESSION[user_id] && $u_level != 9){
    alert("본인의 글이 아닙니다.");
}

// 6. 넘어온 변수 검사
if(trim($_POST[b_title]) == ""){
    alert("글제목을 입력해 주세요.");
}

if(trim($_POST[b_contents]) == ""){
    alert("글내용을 입력해 주세요.");
}

if($board_config[bc_use_secret] && $_POST[b_is_secret] == 1 && trim($_POST[b_pass]) == ""){
    alert("비밀번호를 입력해 주세요.");
}

// 7. 파일삭제가 체크되어 있으면 파일 지우고 파일변수 설정
$dir = "./data";
$b_file = $dir."/".$b_idx;
if($_POST[b_file_del]){
    @unlink($b_file);
    $b_filename = "";
    $b_filesize = 0;
    $file_sql = ", b_filename = '".$b_filename."', b_filesize = '".$b_filesize."'";
}

// 8. 파일 변수 만들기
if($_FILES[b_file][tmp_name]){
    $b_filename = $_FILES[b_file][name];
    $b_filesize = $_FILES[b_file][size];
    $file_sql = ", b_filename = '".$b_filename."', b_filesize = '".$b_filesize."'";
}

// 7. 글저장
$sql = "update ".$_cfg['board_table']." set b_title = '".addslashes(htmlspecialchars($_POST[b_title]))."', b_contents = '".addslashes(htmlspecialchars($_POST[b_contents]))."', b_is_secret = '".$_POST[b_is_secret]."', b_pass = '".$_POST[b_pass]."' ".$file_sql." where b_idx = '".$b_idx."'";
sql_query($sql);


// 10. 파일저장
$dir = "./data";
$b_file = $dir."/".$b_idx;

if($_FILES[b_file][tmp_name] && $b_filename){
    if(file_exists($b_file)){
        @unlink($b_file);
    }
    move_uploaded_file($_FILES[b_file][tmp_name], $b_file);
    chmod($b_file, 0666);

}

// 12. 글목록 페이지로 보내기
alert("글이 저장 되었습니다.", "./board_view.php?bc_code=".$bc_code."&b_idx=".$b_idx."&page=".$_POST[page]);
?>
[board_modify_save.php 소스]

여기서 파일 처리하는 부분은 어드민에서 파일처리하는 부분(http://handsome.pe.kr/76)과 다르게 했습니다.

파일 삭제시나 또는 새로운 파일이 올라왔을때 $file_sql 이라는 sql 문자열을 만들어 쿼리시에 추가하는 방법으로 하였습니다.


글삭제 부분입니다.
<?
// 1. 공통 인클루드 파일
include ("./head.php");

// 2. 게시판 코드 검사
$bc_code = $_GET[bc_code];
if($bc_code){
    // 3. 게시판 코드가 있으면 게시판 설정 불러오기
    $b_config_sql = "select * from ".$_cfg['config_table']." where bc_code = '".$bc_code."'";
    $board_config = sql_fetch($b_config_sql);
}else{
    alert("게시판 코드가 없습니다.");
}

// 4. 존재하는 게시판인지 확인
if(!$board_config[bc_idx]){
    alert("존재 하지 않는 게시판입니다.");
}

// 5. 게시판 권한 체크
if($_SESSION[user_level]){
    $u_level = $_SESSION[user_level];
}else{
    $u_level = 0;
}

// 3. 글 데이터 불러오기
$b_idx = $_GET[b_idx];
$sql = "select * from ".$_cfg['board_table']." where bc_code = '".$bc_code."' and b_idx = '".$b_idx."'";
$data = sql_fetch($sql);

// 4. 글이 없으면 메세지 출력후 되돌리기
if(!$data[b_idx]){
    alert("존재하지 않는 글입니다.");
}

// 5. 본인의 글이 아니면 메세지 출력후 되돌리기
if($data[m_id] != $_SESSION[user_id] && $u_level != 9){
    alert("본인의 글이 아닙니다.");
}

// 6. 파일 과 댓글 삭제하기
$file_sql = "select * from ".$_cfg['board_table']." where bc_code = '".$bc_code."' and b_num = '".$data[b_num]."' and b_reply like '".$data[b_reply]."%'";
$file_result = sql_query($file_sql);

while($file_data = mysql_fetch_array($file_result)){
    // 6-1 파일 삭제
    $dir = "./data";
    $b_file = $dir."/".$file_data[b_idx];
    @unlink($b_file);

    // 6-2 댓글 삭제
    $comment_delete = "delete from ".$_cfg['comment_table']." where b_idx = '".$file_data[b_idx]."'";
    sql_query($comment_delete);
}

// 7. 글 삭제하기
$sql_delete = "delete from ".$_cfg['board_table']." where bc_code = '".$bc_code."' and b_num = '".$data[b_num]."' and b_reply like '".$data[b_reply]."%'";
sql_query($sql_delete);


// 8. 글목록 페이지로 보내기
alert("글이 삭제 되었습니다.", "./board_list.php?bc_code=".$bc_code."&page=".$_GET[page]);
?>
[board_delete.php 소스]

글 삭제시 해당 글의 하위 답글과 댓글들도 모두 삭제 하게 제작이 되었습니다.

그리고 파일도 모두 삭제하게 됩니다.

글을 삭제전에 파일과 댓글들을 앟ㄹ아내야 하기때문에 글삭제전 파일 과댓글을 삭제 하였습니다.

그럼 다음 시간에는 쇼핑몰의 기본이 되는 포인트 몰에 대해서 배워보도록 하겠습니다.
반응형