일반페이지에서 파일첨부시에..
본문
게시판에서 글작성을 해서 첨부파일 다 올리고
일반페이지에서 수정을 하는데 다른 내용들은 다 값이 있는데
첨부된 파일은 값이 없어지는데 머가 잘못 됐을까요 ?
수정 페이지 (게시판 글쓰기 페이지와 동일 수정할 때만 일반페이지로 넘어옴)
<?php
include_once('./_common.php');
include_once('./_head.php');
$sql = " select * from {$g5['poll_table']} where po_id = '{$po_id}' ";
$po = sql_fetch($sql);
$pollScript = '';
$row = sql_fetch(" select po_poll1,po_poll2,po_poll3,po_poll4,po_poll5,po_poll6,po_poll7,po_poll8,po_poll9,po_poll10 from {$g5['poll_table']} where po_id = '$po_id'");
for ($i=1; $i<=10; $i++) {
$memo = get_text(trim($row['po_poll'.$i]));
if (strlen($memo))
$pollScript .= 'addPoll("'.$memo.'");'.PHP_EOL;
elseif ($i<=2)
$pollScript .= 'addPoll("'.$memo.'");'.PHP_EOL;
}
$pollScript = '<script>'.$pollScript.'</script>';
?>
<link rel="stylesheet" href="./css/style.css" type="text/css">
<script type="text/javascript">
var flen = 0;
function addPoll(memo)
{
var poll_count = 10;
if (poll_count && flen >= poll_count)
{
alert("항목은 10개까지 등록 가능합니다.");
return;
}
if (!memo) memo = '';
var objTbl;
var objRow;
var objCell;
if (document.getElementById)
objTbl = document.getElementById('poll_table','variableFiles');
else
objTbl = document.all['poll_table','variableFiles'];
objRow = objTbl.insertRow(objTbl.rows.length);
objCell = objRow.insertCell(0);
objCell.innerHTML = + flen+1 + "번 항목을 입력하세요. <INPUT style='width:300px; height:27px; padding:4px; border:1px solid #c2c2c2; font-weight:bold;' value='" + memo + "' name='po_poll[]' size=7> <input type='file' name='bf_file[]'>";
flen++;
}
<?=$file_script; //수정시에 필요한 스크립트?>
function delPoll()
{
var poll_length = 1;
var objTbl = document.getElementById('poll_table','variableFiles');
if (objTbl.rows.length - 1 > poll_length)
{
objTbl.deleteRow(objTbl.rows.length - 1);
flen--;
}
}
</script>
<section id="bo_w">
<div style="text-align:left; padding-bottom:15px;"><img src="./img/write_title.gif" border=0></div>
<div style="border:1px solid #b7b6b6; padding:25px;">
<form name="fwrite" id="fwrite" action="./poll_form_update.php" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data">
<input type="hidden" name="po_id" value="<?php echo $po_id ?>">
<input type="hidden" name='mb_id' value='<?=$member[mb_id]?>'>
<input type="hidden" name="w" value="<?php echo $w ?>">
<input type="hidden" name="sca" value="<?php echo $sca ?>">
<input type="hidden" name="sfl" value="<?php echo $sfl ?>">
<input type="hidden" name="stx" value="<?php echo $stx ?>">
<input type="hidden" name="sst" value="<?php echo $sst ?>">
<input type="hidden" name="sod" value="<?php echo $sod ?>">
<input type="hidden" name="page" value="<?php echo $page ?>">
<div class="tbl_frm01 tbl_wrap">
<table>
<tbody>
<?
// 분류 사용
$is_category = false;
$category_name = '';
if ($board['bo_use_category']) {
$is_category = true;
if (array_key_exists('ca_name', $write)) {
$category_name = $write['ca_name']; // 분류명
}
}
?>
<tr>
<th scope="row"><label for="ca_name">분 류<strong class="sound_only">필수</strong></label></th>
<td>이 투표는 어떤 투표입니까?
<select name="ca_name" id="ca_name" required >
<?php echo $category_option ?>
</select>
</td>
</tr>
<tr><th style="height:12px; background:#fff; border:1px solid #fff;" colspan="2"></th></tr>
<tr>
<th scope="row"><label for="po_subject">투표제목<strong class="sound_only">필수</strong></label></th>
<td>
<div id="autosave_wrapper">
<input type="text" name="po_subject" value="<?php echo $po['po_subject'] ?>" id="po_subject" required class="input" size="50" maxlength="255">
<span style="font-size:11px; color:#999;">ex) 압구정에서 자주가는 곳은 ?</span>
</div>
</td>
</tr>
<tr><th style="height:12px; background:#fff; border:1px solid #fff;" colspan="2"></th></tr>
<tr>
<th scope="row"><label for="po_multi">투표방법<strong class="sound_only">필수</strong></label></td>
<td>보기는 몇가지 선택이 가능합니까 ?
<select name="po_multi" id="po_multi" required class="required">
<option value="0" <? if($po[po_multi] == 0) echo " selected "; ?>>허용안함 </option>
<option value="2" <? if($po[po_multi] == 2) echo " selected "; ?>> 2개 중복선택 </option>
<option value="3" <? if($po[po_multi] == 3) echo " selected "; ?>> 3개 중복선택 </option>
<option value="4" <? if($po[po_multi] == 4) echo " selected "; ?>> 4개 중복선택 </option>
<option value="5" <? if($po[po_multi] == 5) echo " selected "; ?>> 5개 중복선택 </option>
<option value="6" <? if($po[po_multi] == 6) echo " selected "; ?>> 6개 중복선택 </option>
<option value="7" <? if($po[po_multi] == 7) echo " selected "; ?>> 7개 중복선택 </option>
<option value="8" <? if($po[po_multi] == 8) echo " selected "; ?>> 8개 중복선택 </option>
<option value="9" <? if($po[po_multi] == 9) echo " selected "; ?>> 9개 중복선택 </option>
<option value="10" <? if($po[po_multi] == 10) echo " selected "; ?>> 10개 중복선택 </option>
</select>
</td>
</tr>
<tr><th style="height:12px; background:#fff; border:1px solid #fff;" colspan="2"></th></tr>
<tr>
<th scope="row">투표항목</td>
<td>
<div style="float:left;">
<table id='poll_table' cellpadding=0 cellspacing=0></table><?=$pollScript?>
<table id="variableFiles" cellpadding=0 cellspacing=0></table>
<div style="position:relative; z-index:1; top:-38px; left:680px; float:left;">
<button type="button" style="background:#ee609d; width:35px; height:35px; border:none; color:#fff; font-weight:bold;" onclick="addPoll();return false;" title="추가">+</button>
<button type="button" style="background:#c3c2c3; width:35px; height:35px; border:none; color:#fff; font-weight:bold;" onclick="delPoll();return false;" title="삭제">-</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br /><br />
<div class="btn_confirm">
<input type=image id="btn_submit" src="./img/btn_ok.gif" border=0 accesskey='s'>
<a onclick="javascript:history.go(-1)" style="cursor:hand"><img id="btn_list" src="./img/btn_cancel.gif" border=0></a>
</div>
</form>
<script>
<?php if($write_min || $write_max) { ?>
// 글자수 제한
var char_min = parseInt(<?php echo $write_min; ?>); // 최소
var char_max = parseInt(<?php echo $write_max; ?>); // 최대
check_byte("wr_content", "char_count");
$(function() {
$("#wr_content").on("keyup", function() {
check_byte("wr_content", "char_count");
});
});
<?php } ?>
function html_auto_br(obj)
{
if (obj.checked) {
result = confirm("자동 줄바꿈을 하시겠습니까?\n\n자동 줄바꿈은 게시물 내용중 줄바뀐 곳을<br>태그로 변환하는 기능입니다.");
if (result)
obj.value = "html2";
else
obj.value = "html1";
}
else
obj.value = "";
}
function fwrite_submit(f)
{
<?php echo $captcha_js; // 캡챠 사용시 자바스크립트에서 입력된 캡챠를 검사함 ?>
document.getElementById("btn_submit").disabled = "disabled";
return true;
}
</script>
</section>
<!-- } 게시물 작성/수정 끝 -->
<?
include_once('./_tail.php');
?>
write_update.skin.php
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$items= array();
for ($i=0; $i<=9; $i++) {
$items['po_poll'.$i] = get_text($_POST['po_poll'][$i]);
}
$_POST['po_poll1'] = $items['po_poll0'];
$_POST['po_poll2'] = $items['po_poll1'];
$_POST['po_poll3'] = $items['po_poll2'];
$_POST['po_poll4'] = $items['po_poll3'];
$_POST['po_poll5'] = $items['po_poll4'];
$_POST['po_poll6'] = $items['po_poll5'];
$_POST['po_poll7'] = $items['po_poll6'];
$_POST['po_poll8'] = $items['po_poll7'];
$_POST['po_poll9'] = $items['po_poll8'];
$_POST['po_poll10'] = $items['po_poll9'];
if ($w == '')
{
$sql = " insert {$g5['poll_table']}
( mb_id, po_subject, po_category, po_poll1, po_poll2, po_poll3, po_poll4, po_poll5, po_poll6, po_poll7, po_poll8, po_poll9, po_poll10, po_cnt1, po_cnt2, po_cnt3, po_cnt4, po_cnt5, po_cnt6, po_cnt7, po_cnt8, po_cnt9, po_cnt10, po_etc, po_multi, po_level, po_point, po_date )
values ( '{$member['mb_id']}', '{$_POST['po_subject']}', '{$_POST['po_category']}', '{$_POST['po_poll1']}', '{$_POST['po_poll2']}', '{$_POST['po_poll3']}', '{$_POST['po_poll4']}', '{$_POST['po_poll5']}', '{$_POST['po_poll6']}', '{$_POST['po_poll7']}', '{$_POST['po_poll8']}', '{$_POST['po_poll9']}', '{$_POST['po_poll10']}', '{$_POST['po_cnt1']}', '{$_POST['po_cnt2']}', '{$_POST['po_cnt3']}', '{$_POST['po_cnt4']}', '{$_POST['po_cnt5']}', '{$_POST['po_cnt6']}', '{$_POST['po_cnt7']}', '{$_POST['po_cnt8']}', '{$_POST['po_cnt9']}', '{$_POST['po_cnt10']}', '{$_POST['po_etc']}', '{$_POST['po_multi']}', '{$_POST['po_level']}', '{$_POST['po_point']}', '".G5_TIME_YMDHIS."' ) ";
sql_query($sql);
$po_id = mysql_insert_id();
}
else if ($w == 'u')
{
$sql = " update {$g5['poll_table']}
set mb_id = '{$member['mb_id']}',
po_subject = '{$_POST['po_subject']}',
po_category = '{$_POST['po_category']}',
po_poll1 = '{$_POST['po_poll1']}',
po_poll2 = '{$_POST['po_poll2']}',
po_poll3 = '{$_POST['po_poll3']}',
po_poll4 = '{$_POST['po_poll4']}',
po_poll5 = '{$_POST['po_poll5']}',
po_poll6 = '{$_POST['po_poll6']}',
po_poll7 = '{$_POST['po_poll7']}',
po_poll8 = '{$_POST['po_poll8']}',
po_poll9 = '{$_POST['po_poll9']}',
po_poll10 = '{$_POST['po_poll10']}',
po_cnt1 = '{$_POST['po_cnt1']}',
po_cnt2 = '{$_POST['po_cnt2']}',
po_cnt3 = '{$_POST['po_cnt3']}',
po_cnt4 = '{$_POST['po_cnt4']}',
po_cnt5 = '{$_POST['po_cnt5']}',
po_cnt6 = '{$_POST['po_cnt6']}',
po_cnt7 = '{$_POST['po_cnt7']}',
po_cnt8 = '{$_POST['po_cnt8']}',
po_cnt9 = '{$_POST['po_cnt9']}',
po_cnt10 = '{$_POST['po_cnt10']}',
po_etc = '{$_POST['po_etc']}',
po_multi = '{$_POST['po_multi']}',
po_level = '{$_POST['po_level']}',
po_point = '{$_POST['po_point']}',
po_date = '{$_POST['po_date']}'
where po_id = '{$_POST['po_id']}' ";
sql_query($sql);
}
alert("등록완료", "./board.php?bo_table=$bo_table");
?>
답변을 작성하시기 전에 로그인 해주세요.