코스모스팜 스레드

jsp게시판 이미지수정

<%@ page language="java" contentType="text/html; charset=euc-kr" %>
<%@ page import = "java.sql.*, java.util.*" %>
<% request.setCharacterEncoding("euc-kr"); %>

<%
String num = request.getParameter("num"); 
String pass = request.getParameter("pass"); 

String driverName = "com.mysql.jdbc.Driver";
String dbURL = "jdbc:mysql://localhost:3306/test";

    Class.forName(driverName);
    Connection conn = DriverManager.getConnection(dbURL, "root", "dongyang");
    Statement stmt = conn.createStatement();


PreparedStatement pstmt = null;
ResultSet rs = null;

String strSQL = "SELECT pass FROM tblboard WHERE num = ?";
pstmt = conn.prepareStatement(strSQL);
pstmt.setInt(1, Integer.parseInt(num));

rs = pstmt.executeQuery();
rs.next();

String goodpass = rs.getString("pass").trim();
if (pass.equals(goodpass)){
    response.sendRedirect("modify.jsp?num=" + num);
}else{
    response.sendRedirect("modify_pass.jsp?num=" + num);    
}

rs.close();
pstmt.close();
conn.close();
%>

 

     

<%@ page language="java" contentType="text/html; charset=euc-kr" %>
<%@ page import = "java.sql.*, java.util.*" %>
<% request.setCharacterEncoding("euc-kr"); %>

<%
int num  = Integer.parseInt(request.getParameter("num"));
String name = request.getParameter("name");
String pass = request.getParameter("pass");
String email = request.getParameter("email");
String title = request.getParameter("title");
String contents = request.getParameter("contents");


String driverName = "com.mysql.jdbc.Driver";
String dbURL = "jdbc:mysql://localhost:3306/test";

    Class.forName(driverName);
    Connection conn = DriverManager.getConnection(dbURL, "root", "dongyang");
    Statement stmt = conn.createStatement();

PreparedStatement pstmt = null;

Calendar dateIn = Calendar.getInstance();
String indate = Integer.toString(dateIn.get(Calendar.YEAR)) + "-";
indate = indate + Integer.toString(dateIn.get(Calendar.MONTH)+1) + "-";
indate = indate + Integer.toString(dateIn.get(Calendar.DATE)) + " ";
indate = indate + Integer.toString(dateIn.get(Calendar.HOUR_OF_DAY)) + ":";
indate = indate + Integer.toString(dateIn.get(Calendar.MINUTE)) + ":";
indate = indate + Integer.toString(dateIn.get(Calendar.SECOND));

pstmt = conn.prepareStatement("UPDATE tblboard SET name=?, pass=?, email=?, title=?, contents=?, writedate=? WHERE num=?");
pstmt.setString(1, name);
pstmt.setString(2, pass);
pstmt.setString(3, email);
pstmt.setString(4, title);
pstmt.setString(5, contents);
pstmt.setString(6, indate);
pstmt.setInt(7, num);
pstmt.executeUpdate();

pstmt.close();
conn.close();

response.sendRedirect("listboard.jsp");
%>

<%@ page language="java" contentType="text/html; charset=euc-kr" %>
<%@ page import = "java.sql.*, java.util.*" %>
<% request.setCharacterEncoding("euc-kr"); %>

<HTML>
<HEAD>
<TITLE> 앨범 게시판 </TITLE>

<SCRIPT language="JavaScript">
function Check()
{
if (Modify.name.value.length < 1) {
    alert("작성자를 입력하세요.");
    Modify.name.focus(); 
        return false;
    }

if (Modify.pass.value.length < 1) {
    alert("비밀번호를 입력하세요.");
    Modify.pass.focus(); 
    return false;
    }

if (Modify.email.value.indexOf("@") + "" == "-1" ||
    Modify.email.value.indexOf(".") + "" == "-1" ||
    Modify.email.value == "" )
    { 
        alert("E-mail을 입력하세요.");
        Modify.email.focus();
        return false;
    }

if (Modify.title.value.length < 1) {
    alert("글제목을 입력하세요.");
    Modify.title.focus(); 
    return false;
        }

if (Modify.contents.value.length < 1) {
    alert("글내용을 입력하세요.");
    Modify.contents.focus(); 
    return false;
        }

Modify.submit();
}

function list()
{
location.href = "listboard.jsp";
}

</SCRIPT>
</HEAD>

<BODY>

<%
String num = request.getParameter("num"); 

String driverName = "com.mysql.jdbc.Driver";
String dbURL = "jdbc:mysql://localhost:3306/test";


    Class.forName(driverName);
    Connection conn = DriverManager.getConnection(dbURL, "root", "dongyang");
    Statement stmt = conn.createStatement();

PreparedStatement pstmt = null;
ResultSet rs = null;

try {

String strSQL = "SELECT * FROM tblboard WHERE num = ?";
pstmt = conn.prepareStatement(strSQL);
pstmt.setInt(1, Integer.parseInt(num));

rs = pstmt.executeQuery();
rs.next();

String name = rs.getString("name");
String email = rs.getString("email");
String title = rs.getString("title");
String contents = rs.getString("contents").trim();
String writedate = rs.getString("writedate");
int readcount = rs.getInt("readcount");
%>
                   
<center><font size='3'><b> 게시판 글수정 </b></font>                  

<TABLE border='0' width='600' cellpadding='0' cellspacing='0'>
    <TR>
        <TD><hr size='1' noshade>
        </TD>
     </TR>
</TABLE>
                 
<FORM Name='Modify' Action='modify_output.jsp' Method='POST' OnSubmit='return Check()'>
<input type='hidden' name='num' value='<%=num %>'>
      
<TABLE border='0' width='600'>
    <TR>
        <TD width='100' bgcolor='cccccc'>
            <font size='2'><center><b>작성자</b></center></font> 
        </TD>
        <TD>
            <p><input type='text' size='12' name='name' value="<%=name %>"> * 필수 </p>
        </TD>
    </TR>

    <TR>
        <TD width='100' bgcolor='cccccc'>
            <font size='2'><center><b>비밀번호</b></center></font>
        </TD>
        <TD>
            <p><input type='password' size='12' name='pass'> * 필수 </p>
        </TD>
    </TR>

    <TR>
        <TD width='100' bgcolor='cccccc'>
            <font size='2'><center><b>E-mail</b></center></font>
        </TD>
        <TD>
            <font size='2'><input type='text' size='40' maxlength='50' name='email' value="<%=email %>"></font>
        </TD>
    </TR>
    
    <TR>
              <TD colspan='2'>
                 <hr size='1' noshade>
              </TD>
    </TR>

    <TR>
        <TD width='100' bgcolor='cccccc'>
            <font size='2'><center><b>사진</b></center></font>
        </TD>
        <TD>
            <font size='2'>
                           <input type="file" name="userFile">
                           </font>
        </TD>
    </TR>
    
    <TR>
              <TD colspan='2'>
                 <hr size='1' noshade>
              </TD>
    </TR>


    <TR>
        <TD width='100' bgcolor='cccccc'>
            <font size='2'><center><b>글 제목</b></center></font>
        </TD>
        <TD>
            <font size='2'><input type='text' size='70' maxlength='50' name='title' value="<%=title %>"></font>
        </TD>
    </TR>

    <TR>
        <TD bgcolor='cccccc'>
            <font size='2'><center><b>글 내용</b></center></font>
        </TD>
        <TD>
                 <font size='2'>
                 <textarea cols='70' rows='15' wrap='virtual' name='contents'><%=contents %></textarea>
                 </font>
              </TD>
    </TR>
    
    <TR>
        <TD colspan='2'><hr size='1' noshade></TD>
    </TR>

    <TR>
        <TD align='center' colspan='2' width='100%'>
        <TABLE>
            <TR>
                <TD width='200' align='center'>
                    <input Type = 'Reset' Value = '다시 작성'>
                </TD>
                <TD width='200' align='center'>
                    <input Type = 'Button' Value = '수 정 완료' Name='Page' onClick='Check();'>
                </TD>
                <TD width='200' align='center'>
                    <input Type = 'Button' Value = '목록' Name='Page' onClick='list();'>
                </TD>
            </TR>
        </TABLE>
        </TD>
    </TR>
   
</TABLE>

<%
}catch(SQLException e){
       out.print("SQL에러 " + e.toString());
}catch(Exception ex){
       out.print("JSP에러 " + ex.toString());
}finally{  
    rs.close();
    pstmt.close();
    conn.close();
}
%>

</BODY>
</HTML>


 

앨범게시판 수정jsp입니다

 

앨범게시판에서 이름이나, 글제목 , 글내용은 수정이 되는데

사진은 수정이안됩니다.. 

제가 머 혹시 놓치고 있는 부분이 있을까요..?ㅠ 

무제한으로 웹사이트를 만드세요. (코스모스팜 무제한 라이센스)
무제한으로 웹사이트를 만드세요. (코스모스팜 무제한 라이센스)
이미지 사진은 imgur에 업로드한 뒤 링크 걸어주세요.
무제한으로 웹사이트를 만드세요. (코스모스팜 무제한 라이센스)