회원가입페이지 - JoinForm.jsp <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html >
<html>
<head>
<title>회원가입 화면</title>
<link href='../../css/join_style.css' rel='stylesheet' style='text/css'/>
<script type="text/javascript">
//필수 입력 정보인 아이디,비밀번호가 입력됬는지 확인하는 함수
function checkValue()
{
if(!document.userInfo.id.value)
{
alert("아이디를 입력하세요.");
return false;
}
if(!document.userInfo.password.value)
{
alert("비밀번호를 입력하세요.");
return false;
}
//비밀번호와 비밀번호 확인에 입력된 값이 동일한지 확인
if(document.userInfo.password.value != document.userInfo.passwordcheck.value)
{
alert("비밀번호를 동일하게 입력하세요");
return false;
}
}
//취소 버튼 클릭시 로그인 화면으로 이동ㄹ
function goLoginForm()
{
location.href="LoginForm.jsp"
}
</script>
</head>
<body>
<!-- 왼쪽, 오른쪽 바깥여백을 auto로 주면 중앙정렬된다. -->
<div id="wrap">
<br><br>
<b><font size="6" color="gray">회원가입</font></b>
<br><br><br>
<form method="post" action="../pro/insert_Join.jsp" name="userInfo" onsubmit="return CheckValue">
<table>
<tr>
<td id="title">아이디</td>
<td>
<input type="text" name="id" maxlength="50">
<input type="button" value="중복확인" >
</td>
</tr>
<tr>
<td id="title">비밀번호</td>
<td>
<input type="password" name="password" maxlength="50">
</td>
</tr>
<tr>
<td id="title">이름</td>
<td>
<input type="text" name="name" maxlength="50">
</td>
</tr>
<tr>
<td id="title">성별</td>
<td>
<!--
<input type="radio" name="gender" value="남" checked>남
<input type="radio" name="gender" value="여" checked>여
-->
<input type="text" name="gender" maxlength="50">
</td>
</tr>
<tr>
<td id="title">생일</td>
<td>
<!-- <input type="text" name="birtyy" maxlength="4" placeholder="년(4자)" size="6" >
<select name="birthmm">
<option value="">월</option>
<option value="01" >1</option>
<option value="02" >2</option>
<option value="03" >3</option>
<option value="04" >4</option>
<option value="05" >5</option>
<option value="06" >6</option>
<option value="07" >7</option>
<option value="08" >8</option>
<option value="09" >9</option>
<option value="10" >10</option>
<option value="11" >11</option>
<option value="12" >12</option>
</select>
<input type="text" name="birthdd" maxlength="2" placeholder="일" size="4" > -->
<input type="text" name="birth" maxlength="50">
</td>
</tr>
<tr>
<td id="title">이메일</td>
<td>
<!-- <input type="text" name="email1" maxlength="50">@
<select name="email2">
<option>naver.com</option>
<option>daum.net</option>
<option>gmail.com</option>
<option>nate.com</option>
</select>
-->
<input type="text" name="email" maxlength="50">
</td>
</tr>
<tr>
<td id="title">휴대전화</td>
<td>
<input type="text" name="phone" />
</td>
</tr>
<tr>
<td id="title">주소</td>
<td>
<input type="text" size="50" name="address"/>
</td>
</tr>
</table>
<br>
<input type="submit" value="가입"/>
<input type="button" value="취소" onclick="goLoginForm()"/>
</form>
</div>
</body>
</html>
---------------------------JoinForm.jsp 실행 시 화면
-----------------------------------------------------
insert_Join.jsp - 회원가입시 DB입력
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.sql.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("utf-8");
String id = request.getParameter("id");
String password = request.getParameter("password");
String name = request.getParameter("name");
String gender = request.getParameter("gender");
String birth = request.getParameter("birth");
String email = request.getParameter("email");
String phone = request.getParameter("phone");
String address = request.getParameter("address");
Class.forName("com.mysql.jdbc.Driver");
Connection conn = null;
PreparedStatement pstmt = null;
try
{
String jdbcDriver = "jdbc:mysql://localhost:3306/jsp_member?";
String dbUser = "root";
String dbPass = "1234";
String sql = "insert into jsp_member(id,password,name,gender,birth,email,phone,address) values(?,?,?,?,?,?,?,?)";
conn = DriverManager.getConnection(jdbcDriver,dbUser,dbPass);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,id);
pstmt.setString(2,password);
pstmt.setString(3,name);
pstmt.setString(4,gender);
pstmt.setString(5,birth);
pstmt.setString(6,email);
pstmt.setString(7,phone);
pstmt.setString(8,address);
pstmt.executeUpdate();
}
finally
{
if(pstmt != null) try{pstmt.close();} catch(SQLException ex){}
if(conn != null) try{ conn.close();} catch(SQLException ex){}
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>데이터 삽입</title>
</head>
<body>
JSP_MEMBER 테이블에 새로운 레코드 삽입
</body>
</html>
----------------------------------
회원가입 실행시
이렇게 되는데 뭐가 문제인가요?