본문 바로가기

개발과제

CSS 꾸미기 게시판 작성 페이지

이제 슬슬 진짜로 CSS을 마무리 짓겠습니다. 아마 내일도 포스팅으로 CSS 올릴  거에요.

즉 아예 웹 사이트 꾸미는 거를 끝내고 그 다음부턴 이제 제가 직접 제 페이지의 취약점을 찾아보겠습니다.

 

 

일단 오늘은 작성 페이지 입니다.

 

 

-write_board.php

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>게시판 작성 중</title>
        <link rel="stylesheet" href = "/css/style_write.css">
    </head>
    <body>
        <h1>게시판 작성!</h1>
        <?php 
            session_start(); //세션 시작

            if(!isset($_SESSION['login_id'])) {
                //로그인하지 않은 사용자
                header("Location: login.php"); //login 화면으로 바꾼다
                exit(); //이 페이지를 바로 닫는다
            }
        ?>

        <div class='form-0'>

            <form class='form-1' action="write_process_board.php" method="POST"  enctype="multipart/form-data">
                <input class='write-1' type="text" name="title" maxlegth="44" placeholder="제목 입력, 최대 44자까지 가능합니다" required>
                <hr>
                <textarea class='write-2' name="detail" rows="20" cols="20" maxlength="254" placeholder="내용 작성,최대 254자 가능합니다" required></textarea>
                <input class='write-3' type="file" name="file" id="fileToUpload">

                <hr>

                <input class='write-4' type="submit" value="올리기">
            </form>

            <form action="board.php"> 
                <input class='write-5' type="submit" value="돌아가기">
            </form>

            <?php session_start();
                    if (isset($_SESSION['write_error'])) {
                        echo $_SESSION['write_error'];
                        unset($_SESSION['write_error']);
                    }
            ?>

        </div>

    </body>
</html>

 

 

 

 

-fix_board.php

 

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>게시판 수정 중</title>
        <link rel="stylesheet" href = "/css/style_write.css">
    </head>
    <body>
    <h1>게시판 수정!</h1>

        <?php 
            include 'DB_INFO.php'; //데이터 베이스 정보

            //데이터베이스 연결
            $conn = mysqli_connect($host,$username,$password,$db_board);

            //데이터베이스 오류시 종료
            if(mysqli_connect_errno()) {
                die("데이터 베이스 오류: ". mysqli_connect_error());
            }
            
            session_start(); //세션 시작

            if(!isset($_SESSION['login_id'])) {
                //로그인하지 않은 사용자
                header("Location: login.php"); //login 화면으로 바꾼다
                exit(); //이 페이지를 바로 닫는다
            }
            //GET방식으로 board_id 받기
            $board_id = filter_var(strip_tags($_GET['board_id']),FILTER_SANITIZE_SPECIAL_CHARS);

            //작성된 게시물들 조회 문
            $sql = "SELECT * FROM $db_board WHERE board_id = ? ";

            //preparedStatement 적용
            $stmt = mysqli_prepare($conn, $sql);
    
            //바인딩
            mysqli_stmt_bind_param($stmt,'s', $board_id );
            
            //실행
            mysqli_stmt_execute($stmt);

            //실행 결과 가져오기
            $result = mysqli_stmt_get_result($stmt);

            //결과값 가져오기
            $row = mysqli_fetch_assoc($result);
        ?>

        <div class='form-0'>

            <form class='form-1' action="write_process_board.php" method="POST" enctype="multipart/form-data"> 
                <input class='write-1' type="text" name="title" maxlength="44" value="<?php echo $row['title']; ?>" placeholder="제목 입력, 최대 44자까지 가능합니다">
                <hr>
                <textarea class='write-2' name="detail" rows="20" cols="20" maxlength="254" placeholder="내용 작성,최대 254자 가능합니다"><?php echo $row['detail']; ?></textarea>
                <hr>
                <input class='write-3' type="file" name="file" id="fileToUpload">
                <hr>
                <?php
                    if (isset($row['file_name'])) {
                        $file_name = implode('_', array_slice(explode('_', $row['file_name']), 1)); // '_' 문자를 기준으로 분리 후 첫 번째 요소를 제외한 나머지 요소를 모두 합쳐서 파일명을 구성합니다.
                        echo 'FILE: '.$file_name.'';
                    }
                ?>

                <input class='write-4' type="submit" value="수정하기">
                <input type="hidden" name='board_id' value="<?php echo $row['board_id']; ?>">
            </form>


            <?php session_start();
                    if (isset($_SESSION['write_error'])) {
                        echo $_SESSION['write_error'];
                        unset($_SESSION['write_error']);
                    }
                    
                    //prepared 종료
                    mysqli_stmt_close($stmt);
            ?>
        </div>
    </body>
</html>

 

 

 

 

 

-style_write.php

body{
    background-color:#f5f6f7;   
}

h1 {
    text-align: center;
    padding: 10px 10px;
    padding-bottom: 30px;
    border-bottom:1px solid #848484;
}

.form-0 {
    position: relative;
}

.board-top {
    width : 80%;
    height: 50px;
    margin: 0 auto;
    max-width: 100%;
}

hr{
    width: 100%;
}

.form-1 {
    display: flex;
    flex-direction: column;
    width: 1200px;
    margin: 0 auto;
}

.write-1 {
    height: 50px;
    border : none;
    font-size: 40px;
    background-color: #f5f6f7;
    outline: none;
}

.write-2 {
    margin-top: 30px;
    font-size: 15px;
    border: none;
    background-color: #f5f6f7;
    outline: none;
}

.write-3 {
    margin-top: 10px;
}

.write-4 {
    margin-top: 10px;

    width: 70px;
    height: 30px;
    border: none;
    background-color: #f5f6f7;
    Cursor:pointer;
}

.write-5 {
    position: absolute;
    bottom: 0;
    left: 200px;
    width: 70px;
    height: 30px;
    border: none;
    background-color: #f5f6f7;
    Cursor:pointer;
}

 

 

 

게시판 작성 페이지

 

수정 페이지

 

감사합니다.