Notice
Recent Posts
Recent Comments
Link
Coding Note
[Project1] 3. 회원가입 페이지_데이터 연동 본문
회원가입 페이지 데이터 연동시키기!
- 회원가입 jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../resources/css/join.css">
<link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Fruktur&family=Jua&family=Noto+Sans+KR&display=swap">
<script type="text/javascript" src="js/result.js">
</script>
<title>회원가입하기</title>
</head>
<body>
<div class="wrap02">
<a href="index.html"><img src="../resources/img/logo.png" alt="logo" width="160" height="45"></a>
<div class="tbjoin02">
<h5>회원가입하기</h5>
<form name="frmMember02" action="JoinProcess" method="post">
<table>
<tr>
<td>아이디</td>
<td><input type="text" name="id"></td>
</tr>
<tr>
<td>비밀번호</td>
<td><input type="password" name="pwd"></td>
</tr>
<tr>
<td>이름</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>이메일</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>전화번호</td>
<td><input type="text" name="tel"></td>
</tr>
</table>
<input type="button" value="가입하기" onclick="fn_sendMessage()">
<input type="reset" value="다시입력"/>
<input type="hidden" name="command" value="addMember"/>
</form>
</div>
</div>
</body>
</html>
- alert.js
function fn_sendMessage() {
if(frmMember02.id.value==""){
alert("아이디를 입력해주세요.");
frmMember02.id.focus();
}else if(frmMember02.pwd.value==""){
alert("비밀번호를 입력해주세요.");
frmMember02.pwd.focus();
}else if(frmMember02.name.value==""){
alert("이름을 입력해주세요.");
frmMember02.name.focus();
}else if(frmMember02.email.value==""){
alert("이메일을 입력해주세요.");
frmMember02.email.focus();
}else if(frmMember02.tel.value==""){
alert("전화번호를 입력해주세요.");
frmMember02.tel.focus();
}else{
frmMember02.action="/1_TBlog/JoinProcess";
frmMember02.method = "post";
frmMember02.submit();
}
}
- JoinProcess.java
package kr.co.ezenac.join;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import kr.co.ezenac.member.MemberDAO;
import kr.co.ezenac.member.MemberVO;
/**
* Servlet implementation class JoinProcess
*/
@WebServlet("/JoinProcess")
public class JoinProcess extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String _id = request.getParameter("id");
String _pwd = request.getParameter("pwd");
String _name = request.getParameter("name");
String _email = request.getParameter("email");
String _tel = request.getParameter("tel");
MemberVO memberVO = new MemberVO();
memberVO.setId(_id);
memberVO.setPwd(_pwd);
memberVO.setName(_name);
memberVO.setEmail(_email);
memberVO.setTel(_tel);
MemberDAO memberDAO = new MemberDAO();
memberDAO.insertUsert(memberVO);
}
}
- memberDAO
package kr.co.ezenac.member;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class MemberDAO {
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@localhost:1521:XE";
String uesr = ""; // 연동할 오라클 아이디
String pwd = ""; // 연동할 오라클 비밀번호
public void insertUsert(MemberVO memberVO) {
Connection con = null;
PreparedStatement pstmt= null;
String query = "INSERT INTO T_JOIN (ID, PWD, NAME, EMAIL, TEL) "
+ "VALUES (?, ?, ?, ?, ?)";
try {
Class.forName(driver);
con = DriverManager.getConnection(url, uesr, pwd);
pstmt = con.prepareStatement(query);
pstmt.setString(1, memberVO.getId());
pstmt.setString(2, memberVO.getPwd());
pstmt.setString(3, memberVO.getName());
pstmt.setString(4, memberVO.getEmail());
pstmt.setString(5, memberVO.getTel());
pstmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
}
}
- memberVO
package kr.co.ezenac.member;
/* 오라클 선언 컬럼명
* id varchar2(10) PRIMARY KEY
,pwd varchar2(20) NOT NULL
,name varchar2(10) NOT NULL
,email varchar2(30) NOT NULL
,tel varchar2(20) NOT NULL
*
*/
public class MemberVO {
private String id;
private String pwd;
private String name;
private String email;
private String tel;
public MemberVO() {
// TODO Auto-generated constructor stub
}
public MemberVO(String id, String pwd, String name, String email, String tel) {
super();
this.id = id;
this.pwd = pwd;
this.name = name;
this.email = email;
this.tel = tel;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
}
- 오라클 데이터 연동 결과
'My' 카테고리의 다른 글
[Project1] 2. 여행 사이트 로그인 페이지 (0) | 2021.12.15 |
---|---|
[Project1] 1. 여행 사이트 메인 페이지 (0) | 2021.12.15 |
미니 CGV 웹 페이지 프로젝트 (0) | 2021.12.13 |
Comments