회원가입 디비 연결

it 2014. 8. 22. 18:10 Posted by 하얀나다

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>회원가입</title>

<!-- js, css, jquery 지정 -->

<link rel="stylesheet" href="css/myform1.css" type="text/css"

media="screen" charset="utf-8" />

<script src="../lib/jquery-1.9.1.min.js" type="text/javascript"

charset="utf-8"></script>

<script type="text/javascript" src="../jquery/jquery.js"></script>


</head>

<body>

<form name="frm" id="frm" METHOD="get" ACTION="MemberForm.jsp">

<fieldset>

<legend>회원가입</legend>

<ol>

<li><label for="userId">아이디</label> <input type="text"

name="userId" placeholder="아이디를 만들어주세요" id="userId" required /> <input

type="button" name="idbutton" value="중복확인"></li>


<li><label for="userPw">패스워드</label> <input type="password"

name="userPw" placeholder="5자미만공백없이입력" id="userPw" required /></li>


<li><label for="userPwre">패스워드확인</label> <input type="password"

name="userPwre" placeholder="다시한번 입력해주세요" id="userPwre" required  /></li>


<li><label for="name">이름</label> <input type="text" name="name"

placeholder="이름을 입력하세요" id="name" required /></li>


<!-- 메일 -->

<li><label for="email">이메일</label> <input type="text"

name="email" size="10"> @ <select name="email1">

<option value="naver.com">naver.com</option>

<option value="daum.net">daum.net</option>

<option value="nate.com">nate.com</option>

<option value="yahoo.com">yahoo.com</option>

</select></li>


<li><label for="address">주소</label> <input type="text"

name="address1" size="3" required /> - <input type="text"

name="address2" size="3" required /> <input type="button"

name="addbutton" value="우편번호"> <br /> <input type="text"

name="address3" size="28" /> <br /> <input type="text"

name="address4" size="28" /></li>





<tr>

<td colspan="2"><input type="submit"

value="회&nbsp;&nbsp;원&nbsp;&nbsp;가&nbsp;&nbsp;입" size="15"></td>

<td colspan="2"><input type="submit"

value="취&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;소"

size="15"></td>

</tr>

</ol>

</fieldset>

</form>

</body>

</html>






<%@ page import="java.sql.*"%>

<%@ page import="java.io.*"%>

<%@ page language="java" contentType="text/html; charset=EUC-KR"

pageEncoding="utf-8"%>

<!--  이전 화면에서의 사용자 입력값 얻어오기 -->


<%

//주석주석해

request.setCharacterEncoding("utf-8");

//한글안꺠져


String userId = request.getParameter("userId");

String userPw = request.getParameter("userPw");

String name = request.getParameter("name");

String email = request.getParameter("email");

String email1 = request.getParameter("email1");

String emaile = email + "@" + email1;

String address1 = request.getParameter("address1");

String address2 = request.getParameter("address2");

String address3 = request.getParameter("address3");

String address4 = request.getParameter("address4");

String address = address1 + " - " + address2 + " " + address3 + address4;

%>


<%

Connection con = null;

PreparedStatement ps = null;

ResultSet rs = null;


// 1. 드라이버 로딩

Class.forName("oracle.jdbc.driver.OracleDriver");


// 2. 연결객체 얻어오기

con = DriverManager.getConnection(

"jdbc:oracle:thin:@localhost:1521:orcl", "scott", "tiger");


// 3. sql 문장 만들기

String sql = "insert  into imsi (id, pass, name, email, addr) values(?,?,?,?,?)";


// 4. sql 전송객체 얻어오기

ps = con.prepareStatement(sql);

ps.setString(1, userId);

ps.setString(2, userPw);

ps.setString(3, name);

ps.setString(4, emaile);

ps.setString(5, userId);


// 5. 전송

ps.executeUpdate();

ps.close();

%>


<!-- 화면출력 -->

<!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">

<title>폼의 결과값</title>

</head>

<body>



입력하신 아이디는

<%=userId%><br /> 비밀번호는

<%=userPw%>

<br /> 이름은

<%=name%>

<br /> 이메일은

<%=email%>@<%=email1%><br /> 우편번호

<%=address1%>

-

<%=address2%><br /> 상세주소

<%=address3%>

<%=address4%>

<br />



</body>

</html>







'it' 카테고리의 다른 글

언어의 종류  (0) 2015.06.17
정보넘기기 안될때  (0) 2014.08.22
jsp 정보 넘기기.  (0) 2014.08.22
서버 시간 확인.  (0) 2014.08.12