입력폼에서 자바스크립트를 이용하여 필수 입력사항을 검사하는 처리를 추가합니다.
1. 글쓰기 폼 페이지
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>게시판 > 글쓰기</title>
<link rel="stylesheet" type="text/css" href="./css/common.css">
<link rel="stylesheet" type="text/css" href="./css/board.css">
<script type="text/javascript" src="./js/board.js"></script>
</head>
<body>
<header>
<?php include "header.php";?>
</header>
<section>
<div id="board_box">
<h3 id="board_title">
게시판 > 글 쓰기
</h3>
<form name="board_form" method="post" action="board_insert.php" enctype="multipart/form-data">
<ul id="board_form">
<li>
<span class="col1">이름 : </span>
<span class="col2"><?=$username?></span>
</li>
<li>
<span class="col1">제목 : </span>
<span class="col2"><input name="subject" type="text"></span>
</li>
<li id="text_area">
<span class="col1">내용 : </span>
<span class="col2">
<textarea name="content"></textarea>
</span>
</li>
<li>
<span class="col1"> 첨부 파일</span>
<span class="col2"><input type="file" name="upfile"></span>
</li>
</ul>
<ul class="buttons">
<li><button type="button" onclick="check_input()">완료</button></li>
<li><button type="button" onclick="location.href='board_list.php'">목록</button></li>
</ul>
</form>
</div> <!-- board_box -->
</section>
<footer>
<?php include "footer.php";?>
</footer>
</body>
</html>
2. 글 수정 폼 페이지
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>게시판 > 글수정</title>
<link rel="stylesheet" type="text/css" href="./css/common.css">
<link rel="stylesheet" type="text/css" href="./css/board.css">
<script type="text/javascript" src="./js/board.js"></script>
</head>
<body>
<header>
<?php include "header.php";?>
</header>
<section>
<div id="board_box">
<h3 id="board_title">
게시판 > 글 쓰기
</h3>
<?php
$num = $_GET["num"];
$page = $_GET["page"];
$con = mysqli_connect("localhost", "user1", "12345", "sample");
$sql = "select * from board where num=$num";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
$name = $row["name"];
$subject = $row["subject"];
$content = $row["content"];
$file_name = $row["file_name"];
?>
<form name="board_form" method="post" action="board_modify.php?num=<?=$num?>&page=<?=$page?>" enctype="multipart/form-data">
<ul id="board_form">
<li>
<span class="col1">이름 : </span>
<span class="col2"><?=$name?></span>
</li>
<li>
<span class="col1">제목 : </span>
<span class="col2"><input name="subject" type="text" value="<?=$subject?>"></span>
</li>
<li id="text_area">
<span class="col1">내용 : </span>
<span class="col2">
<textarea name="content"><?=$content?></textarea>
</span>
</li>
<li>
<span class="col1"> 첨부 파일 : </span>
<span class="col2"><?=$file_name?></span>
</li>
</ul>
<ul class="buttons">
<li><button type="button" onclick="check_input()">수정하기</button></li>
<li><button type="button" onclick="location.href='board_list.php'">목록</button></li>
</ul>
</form>
</div> <!-- board_box -->
</section>
<footer>
<?php include "footer.php";?>
</footer>
</body>
</html>