IT새내기IM 2023. 1. 21. 17:12

 

join,joininsert

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/include/header.jsp" %>

<table height=50><tr><td></td></tr></table>
<table width=1200 border=0 align="center">
	<tr>
		<td align=center>[회원가입]</td>
	</tr>
</table>

<script>
function join_ok(){
	if(m_id.value == ""){            
// 		id나 class를 써야 .value를 쓸 수 있다.
		alert("아이디 입력하시오");
		m_id.focus();
		return;
	}
	if(m_pass.value == ""){            
		alert("비밀번호 입력하시오");
		m_pass.focus();
		return;
	}
	if(m_name.value == ""){            
		alert("이름을 입력하시오");
		m_name.focus();
		return;
	}
	document.join.submit();
}
</script>

<form name="join" action="insert.jsp" method="post">
<table width=700 border=0 align="center">
	<tr>
		<td align=center height=70 width=200>아이디</td>
		<td style="text-align:left;" height=50 width=500><input id="m_id" name="m_id" class=input2>&nbsp&nbsp<input type="button" value="아이디 중복체크" class=button onclick="" style="font-size:15px;font-family: 'Jua', cursive;" size=5></td>
	</tr>
	<tr>
		<td align=center height=70 width=200>비밀번호</td>
		<td style="text-align:left;" height=50 width=500><input id="m_pass" name="m_pass" class=input2></td>
	</tr>
	<tr>
		<td align=center height=70 width=200>이름</td>
		<td style="text-align:left;" height=50 width=500><input id="m_name" name="m_name" class=input2></td>
	</tr>
	<tr>
		<td align=center height=70 width=200>메일주소</td>
		<td style="text-align:left;" height=50 width=500>
			<input id="m_email1" name="m_email1" class=input3> @
			<input id="m_email2" name="m_email2" class=input3>
			<select id="domain" onchange="m_email2.value = this.value" style="border-radius: 15px 15px 15px 15px;width:20%;height:50%">
				<option value="">= 직접입력 =</option>
				<option value="naver.com">naver.com</option>
				<option value="gmail.com">gmail.com</option>
				<option value="nate.com">nate.com</option>
			</select>
		</td>
	</tr>
	<tr>
		<td align=center height=70 width=200>생년원일</td>
		<td style="text-align:left;" height=50 width=500>
			<table width=61% border=0>
				<tr>
					<td width=15><input id="birth_01" name="birth_01" style="background-color:white;width:90%;border:0px;font-weight:bold;border-radius: 15px 15px 15px 15px;height:30px;text-align:center;" placeholder="년(4자)"></td>
					<td width=1></td>
					<td width=15>
					<select name="birth_02" style="background-color:white;width:90%;border:0px;font-weight:bold;border-radius: 15px 15px 15px 15px;height:30px;text-align:center;">
                            <option value="1">월</option>
                            <option value="2">1</option>
                            <option value="3">2</option>
                            <option value="4">3</option>
                            <option value="5">4</option>
                            <option value="6">5</option>
                            <option value="7">6</option>
                            <option value="8">7</option>
                            <option value="9">8</option>
                            <option value="10">9</option>
                            <option value="11">10</option>
                            <option value="12">11</option>
                            <option value="13">12</option>
                             </select>
					</td>
					<td width=1></td>
					<td width=15><input id="birth_03" name="birth_03" style="background-color:white;width:90%;border:0px;font-weight:bold;border-radius: 15px 15px 15px 15px;height:30px;text-align:center;" placeholder="일" ></td>
				</tr>
			</table>

		</td>
	</tr>
	<tr>
		<td align=center height=70 width=200>성별</td>
		<td style="text-align:left;" height=50 width=500>
			<select name="gender" class=sel1 style="text-align:center;">
				<option value="성별">성별</option>
				<option value="남성">남성</option>
				<option value="여성">여성</option>
				<option value="선택안함">선택안함</option>
			</select>
		</td>
	</tr>
	<tr>
		<td align=center height=70 width=200>주소</td>
		<td height=70>
			<input type="text" id="sample4_postcode" name="zipcode" style="font-weight:bold;height:50%;border:0px;width:200px;border-radius: 15px 15px 15px 15px;" placeholder="우편번호">
			<input type="button" onclick="sample4_execDaumPostcode()" value="우편번호 찾기" class=button>
		</td>
	</tr>
	<tr>
		<td></td>
		<td>
			<input type="text" id="sample4_roadAddress" name="zipcode1" style="font-weight:bold;height:30px;border:0px;width:145px;border-radius: 15px 15px 15px 15px;" placeholder="도로명주소">
			<input type="text" id="sample4_jibunAddress" name="zipcode2" style="font-weight:bold;height:30px;border:0px;width:145px;border-radius: 15px 15px 15px 15px;" placeholder="지번주소">
			<span id="guide" style="color:#999;display:none"></span>
		</td>
	</tr>
	<tr height=10></tr>
	<tr>
		<td></td>
		<td>
			<input type="text" id="sample4_detailAddress" name="zipcode3" style="font-weight:bold;height:30px;border:0px;width:145px;border-radius: 15px 15px 15px 15px;" placeholder="상세주소">
			<input type="text" id="sample4_extraAddress" name="zipcode4" style="font-weight:bold;height:30px;border:0px;width:145px;border-radius: 15px 15px 15px 15px;" placeholder="참고항목">
		</td>
	</tr>
	<tr height=20></tr>
	<tr>
		<td align=center>연락처</td>
		<td>
		<input id="m_phone1" name="m_phone1" style="font-weight:bold;height:30px;border:0px;width:87px;border-radius: 15px 15px 15px 15px;">-
		<input id="m_phone2" name="m_phone2" style="font-weight:bold;height:30px;border:0px;width:87px;border-radius: 15px 15px 15px 15px;">-
		<input id="m_phone3" name="m_phone3" style="font-weight:bold;height:30px;border:0px;width:87px;border-radius: 15px 15px 15px 15px;">
		</td>
	</tr>
	<tr height=20></tr>	
	<tr>
		<td align=center></td>
		<td>
			<a href="../index.jsp"><input type="button" value="취소" class=button style="font-size:18px;font-family: 'Jua', cursive;"></a>
			<input type="button" value="회원가입" onclick="join_ok()" class=button style="font-size:18px;font-family: 'Jua', cursive;">
		</td>
	</tr>
</table>
</form>

<!-- 우편번호시작 -->

<script src="//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>
<script>
    //본 예제에서는 도로명 주소 표기 방식에 대한 법령에 따라, 내려오는 데이터를 조합하여 올바른 주소를 구성하는 방법을 설명합니다.
    function sample4_execDaumPostcode() {
        new daum.Postcode({
            oncomplete: function(data) {
                // 팝업에서 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분.

                // 도로명 주소의 노출 규칙에 따라 주소를 표시한다.
                // 내려오는 변수가 값이 없는 경우엔 공백('')값을 가지므로, 이를 참고하여 분기 한다.
                var roadAddr = data.roadAddress; // 도로명 주소 변수
                var extraRoadAddr = ''; // 참고 항목 변수

                // 법정동명이 있을 경우 추가한다. (법정리는 제외)
                // 법정동의 경우 마지막 문자가 "동/로/가"로 끝난다.
                if(data.bname !== '' && /[동|로|가]$/g.test(data.bname)){
                    extraRoadAddr += data.bname;
                }
                // 건물명이 있고, 공동주택일 경우 추가한다.
                if(data.buildingName !== '' && data.apartment === 'Y'){
                   extraRoadAddr += (extraRoadAddr !== '' ? ', ' + data.buildingName : data.buildingName);
                }
                // 표시할 참고항목이 있을 경우, 괄호까지 추가한 최종 문자열을 만든다.
                if(extraRoadAddr !== ''){
                    extraRoadAddr = ' (' + extraRoadAddr + ')';
                }

                // 우편번호와 주소 정보를 해당 필드에 넣는다.
                document.getElementById('sample4_postcode').value = data.zonecode;
                document.getElementById("sample4_roadAddress").value = roadAddr;
                document.getElementById("sample4_jibunAddress").value = data.jibunAddress;
                
                // 참고항목 문자열이 있을 경우 해당 필드에 넣는다.
                if(roadAddr !== ''){
                    document.getElementById("sample4_extraAddress").value = extraRoadAddr;
                } else {
                    document.getElementById("sample4_extraAddress").value = '';
                }

                var guideTextBox = document.getElementById("guide");
                // 사용자가 '선택 안함'을 클릭한 경우, 예상 주소라는 표시를 해준다.
                if(data.autoRoadAddress) {
                    var expRoadAddr = data.autoRoadAddress + extraRoadAddr;
                    guideTextBox.innerHTML = '(예상 도로명 주소 : ' + expRoadAddr + ')';
                    guideTextBox.style.display = 'block';

                } else if(data.autoJibunAddress) {
                    var expJibunAddr = data.autoJibunAddress;
                    guideTextBox.innerHTML = '(예상 지번 주소 : ' + expJibunAddr + ')';
                    guideTextBox.style.display = 'block';
                } else {
                    guideTextBox.innerHTML = '';
                    guideTextBox.style.display = 'none';
                }
            }
        }).open();
    }
</script>
<!-- 우편번호끝 -->

<table height=200 border=1><tr><td></td></tr></table>

<%@ include file="/include/footer.jsp" %>

<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/include/header.jsp" %>

  <%
  //넘어온 값들에 한글이 있다면 캐릭터 셋 - 매칭 처리한다.
  request.setCharacterEncoding("utf-8");
  //4대 내장 객체 중 request (전 페이지에서 넘어오는 객체를 받을 떄 사용하는)
  String id = request.getParameter("m_id");
  String pass = request.getParameter("m_pass");
  String name = request.getParameter("m_name");
  String email1 = request.getParameter("m_email1");
  String email2 = request.getParameter("m_email2");
  
  String z = request.getParameter("zipcode");  //form태그에서 받아온 값
  String z1 = request.getParameter("zipcode1");
  String z2 = request.getParameter("zipcode2");
  String z3 = request.getParameter("zipcode3");
  String z4 = request.getParameter("zipcode4");
  
  String p1 = request.getParameter("m_phone1");
  String p2 = request.getParameter("m_phone2");
  String p3 = request.getParameter("m_phone3");
  
  String b1 = request.getParameter("birth_01");
  String b2 = request.getParameter("birth_02");
  String b3 = request.getParameter("birth_03");

  String g = request.getParameter("gender");
  
  String sql = "insert into member2 values ('"+id+"','"+pass+"','"+name+"','"+email1+"','"+email2+"','1','"+z+"','"+z1+"','"+z2+"','"+z3+"','"+z4+"','"+p1+"','"+p2+"','"+p3+"','"+b1+"','"+b2+"','"+b3+"','"+g+"')";
  
	Connection con = DriverManager.getConnection(url, user, password); //dbconnection의 변수
	Statement stmt = con.createStatement();
	stmt.executeUpdate(sql); // insert, update, delete 구문에서는 executeUpdate(); 메소드를 씀
	%>
  <script>
  	location.href="/";
  </script>
  %>