<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page import="java.sql.*"%>
<% request.setCharacterEncoding("euc-kr");%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<style>
b {
font-size: 13px;
font-family: 굴림;
color: #E6B9B8;}
.sign{
position: absolute;
left: 1%;
right: 1%;
top: 350px;}
.back{
position: absolute;
left: 1%;
right: 1%;
top: 400px;}
</style>
<script type="text/javascript">
var right = 0;
function regChk(){
var userid = document.form.userid.value;
var passwd = document.form.passwd.value;
var email = document.form.email.value;
var kname = document.form.kname.value;
<%-- var regx = /^[a-zA-Z0-9.]*$@-_/; --%>
var form = document.form;
if(userid.length==0 || userid==null){
alert("아이디를 입력하십시오");
form.userid.focus();
return false;
}
if (passwd.length==0 || passwd==""){
alert("비밀번호를 입력하십시오");
form.passwd.focus();
return false;
}
if (kname.length==0 || kname==null){
alert("이름을 입력하십시오");
return false;
}
if (email.length==0 || email==null){
alert("이메일을 입력하십시오");
return false;
}
<%-- if (!regx.test(email)){
alert("이메일은 영어, 숫자만 입력가능합니다.");
document.form.email.focus();
return false;
}--%>
location.href="signinProc.jsp";
document.form.submit();
}
function passchk(){
var passwd = document.form.passwd.value;
var pass2 = document.form.pass2.value;
if (pass2.length == 0 || pass2 == null) {
document.form.chk.value = "비밀번호를 입력하세요";
right=0;
} else if (passwd != pass2) {
document.form.chk.value = "비밀번호가 다릅니다.";
right=0;
} else {
document.form.chk.value = "비밀번호가 동일합니다.";
right=1;
}
return;
}
function idcheck(){
var userid = document.form.userid.value;
if(userid.length<1 || userid==null){
alert("중복체크할 아이디를 입력하십시오");
return false;
}
var url = "idCheck.jsp?id=" + userid;
window.open(url, "get", "height = 180, width = 300");
}
function cancel(){
if(confirm("정말 취소하시겠습니까?")){
location.href="nologin.jsp";
}
else{
return false;
}
}
</script>
<title>떠들자</title>
</head>
<body>
<div>
<img src="image/logo.png"><br>
</div>
<div>
<img src="image/signinlogo.png"><br>
</div>
<form name="form" method="post" action="signinProc.jsp">
<b>아이디 </b> @
<input type="text" size="10" maxlength="255" name="userid" >
<img src="image/idchk.png" onclick="idcheck()" align="middle"><br><br>
<b>비밀번호 </b>
<input type="password" size="10px" maxlength="255" name="passwd" class="inputpass"><br><br>
<b>비밀번호 확인 </b>
<input type="password" size="15" maxlength="20" name="pass2" onblur="passchk()">
<input type="text" style="border-width: 0px" size="20" name="chk" value="비밀번호를 입력하세요" readonly="readonly"><br><br>
<b>이름 </b>
<input type="text" size="13" maxlength="12" name="kname"><br><br>
<b>이메일 </b>
<input type="text" size="20" maxlength="120" name="email">
<div>
<a href="javascript:submitValue();" style="background-color: #E6B9B8 ;text-decoration: none; color:white; text-align:center; line-height:32px" class="sign" onclick="regChk()">회원가입</a>
</div>
<div>
<a style="background-color: #E6B9B8 ;text-decoration: none; color:white; text-align:center; line-height:32px" class="back" onclick="cancel()">메인으로 돌아가기</a>
</div>
</form>
</body>
</html>
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page import="java.sql.*"%>
<%
request.setCharacterEncoding("euc-kr");
String sql="";
String userid= request.getParameter("userid");
String passwd = request.getParameter("passwd");
String kname = request.getParameter("kname");
String email = request.getParameter("email");
Connection conn=null;
PreparedStatement pstmt=null;
try{
String jdbcUrl="jdbc:mysql://localhost:3306/jsptest";
String dbId="jsptest";
String dbPass="1234ab";
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection(jdbcUrl,dbId ,dbPass);
sql= "insert into member1 values (?,?,?,now(),?)";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,userid);
pstmt.setString(2,passwd);
pstmt.setString(3,kname);
pstmt.setString(4,email);
System.out.println("****************"+sql);
pstmt.executeUpdate();
}catch(Exception e){
e.printStackTrace();
}finally{
if(pstmt != null) try{pstmt.close();}catch(SQLException sqle){}
if(conn != null) try{conn.close();}catch(SQLException sqle){}
}
%>
<html>
<head>
<title>떠들자</title>
</head>
<body>
회원가입을 축하드립니다.
</body>
</html>
네 이렇게 했는데요..아직 인터넷으로 여기저기 긁어서 하다보니 통일성이 없지않아 있긴 합니다만..
양식에서 글쓰고 DB로 값이 넘어가긴하는데, 페이지는 한번에 안넘어가고 몇번 클릭해야 넘어가요.
어떤 부분에서 수정을해야 할까요?
아, 그리고 DB에서 한글이 ???로 나오는데 이거는 어떻게 또 해야하나요..인터넷에 하라는대로는 하긴했는데. 안돼네요 ㅠㅠ
SQLgate for MySQL 쓰고요 부탁드려요 ㅠ