답변 3개 / 댓글 4개
채택된 답변
+20 포인트
# html 부분
Copy
<form action="./gawibawibo_delete.php" onsubmit="check(this)"> <input type="text" name="mb_id"> <input type="submit" value="삭제"></form> <script type="text/javascript"> function check(f) { if (!f.mb_id.value) { alert('아이디를 입력해 주세요.'); f.mb_id.focus(); } if (!confirm('입력한' + f.mb_id.value + ' 아이디를 정말 삭제하시겠습니까?')) return false; }</script>
# update 부분
Copy
include_once('./common.php'); // 입력한 아이디가 있는지 조회한다.$result = sql_fetch("select mb_id from g4_gawibawibo where mb_id = {$mb_id}"); if ($result['mb_id']) sql_query("delete from g4_gawibawibo where mb_id = {$mb_id}");else alert("입력한 {$mb_id} 아이디는 존재하지 않습니다.");
답변에 대한 댓글 3개
감사합니다 다들 도움 되었습니다 ^^ 알려주신것과 도움주신것과 오류등을 해석하여 수정합니다.
Copy
<?php if ($is_admin) {?> <form action="./gawibawibo_delete.php" onsubmit="return check(this)"> <input type="text" name="mb_id"> <input type="submit" value="삭제"> </form> <script type="text/javascript"> function check(f) { if (!f.mb_id.value) { alert('아이디를 입력해 주세요.'); f.mb_id.focus(); return false; } if (!confirm('입력한' + f.mb_id.value + ' 아이디를 정말 삭제하시겠습니까?')) return false; } </script> <? } ?>
# update 부분
Copy
<?include_once('./_common.php'); // 입력한 아이디가 있는지 조회한다.$result = sql_fetch("select mb_id from g4_gawibawibo where mb_id = '$mb_id'"); if ($result['mb_id']) sql_query("delete from g4_gawibawibo where mb_id = '$mb_id'");else alert("입력한 {$mb_id} 아이디는 존재하지 않습니다.");?>
...
삭제화면
<form action="del.php" method="post">
<input type="text" name="mb_id" size="30">
<input type="submit" name="submit" value="삭제">
</form>
del.php
...
$query = "delete from g4_gawibawibo where mb_id='$mb_id' ";
$result = mysql_query($query, mysql_connect("localhost","아이디","비밀번호") or die (mysql_error()));
...
<script type="text/javascript">
location.href="이동할 url";
</script>
=========================================================================
꿀꿀*코구녕님과 같은, 그누고수님들께는 班门弄斧 (반문농부) 격의 답변이 되겠군요.
허접한 프로그램입니다만, 작게나마 도움이 될수 있었으면 하는 바램입니다. ㅎㅎ
답변을 작성하려면 로그인이 필요합니다.
여기에 return 붙여 주셔야 합니다.
onsubmit="return check(this)">
그리고
f.mb_id.focus();
밑에 return false; 붙여 주셔야 하구요.