회원가입 DB 연동

This commit is contained in:
mcutegs2
2020-06-23 17:52:42 +09:00
parent 939483e336
commit e55cee847a
15 changed files with 208 additions and 100 deletions

View File

@@ -43,16 +43,24 @@ public class UserJoinDao extends BasicDao {
UserJoinVo vo = null;
try {
this.psmt = this.conn.prepareStatement("SELECT * FROM user_tbl WHERE id = ? and pw = ?");
this.psmt.setString(1, member.getU_ID());
this.psmt = this.conn.prepareStatement("SELECT * FROM user_tbl WHERE u_ID ='?' and u_psw ='?'");
//this.psmt = this.conn.prepareStatement("SELECT u_ID, u_psw FROM user_tbl");
// while(this.rs.next()) {
// member = new UserJoinVo();
//member.setU_ID(this.rs.getString("u_ID"));
//member.setU_psw(this.rs.getString("u_psw"));
//}
this.psmt.setString(1, member.getU_ID());
this.psmt.setString(2, member.getU_psw());
this.rs = this.psmt.executeQuery();
this.rs = this.psmt.executeQuery();
if (this.rs.next()) {
vo = new UserJoinVo();
// vo = new UserJoinVo();
String id = this.rs.getString("u_ID");
String pw = this.rs.getString("u_pwd");
vo.setU_ID(id);
vo.setU_psw(pw);
String pw = this.rs.getString("u_psw");
vo = new UserJoinVo(id, pw); // 이거 왜 이러냐 개샤ㅐ끼야
//vo.setU_ID(id);
//vo.setU_psw(pw);
}
} catch (SQLException var5) {
var5.printStackTrace();

View File

@@ -12,6 +12,8 @@ public class UserJoinVo {
public String u_divi;
public String u_car_num;
public String getU_ID() {
return u_ID;
}

View File

@@ -0,0 +1,34 @@
package command;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import UserJoin.UserJoinDao;
import UserJoin.UserJoinVo;
public class UserLoginCheckCommand implements Command {
public String exec(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
UserJoinDao dao = new UserJoinDao();
UserJoinVo member = null;
String id = request.getParameter("u_ID");
String pw = request.getParameter("u_psw");
System.out.println("u_ID : " + id);
System.out.println("u_psw : " + pw);
id = id.trim();
pw = pw.trim();
member = dao.selectMember(member);
request.setAttribute("member", member);
String path;
if (member != null) {
path = "loginOk.jsp";
} else {
path = "loginFail.jsp";
}
return path;
}
}

View File

@@ -15,6 +15,7 @@ import command.BoardViewCommand;
import command.Command;
import command.HomeCommand;
import command.UserJoinCommand;
import command.UserLoginCheckCommand;
import command.UserLoginCommand;
import command.UserRegCommand;
import command.patientJoinCommand;
@@ -40,6 +41,7 @@ public class Fcontroller extends HttpServlet {
list.put("/UserReg.do", new UserRegCommand()); // 임직원 회원가입 페이지
list.put ("/patientJoin.do", new patientJoinCommand()); // 환자 회원가입 페이지
list.put("/boardView.do", new BoardViewCommand()); // 데이터 보기 test 페이지
list.put("/loginCheck.do", new UserLoginCheckCommand());
//이 부분에 계속적으로 매핑을 추가하면 됨
}

View File

@@ -0,0 +1,5 @@
package patientJoin;
public class patientJoinDao {
}

View File

@@ -0,0 +1,5 @@
package patientJoin;
public class patientJoinVo {
}

View File

@@ -1,77 +0,0 @@
package user;
import java.sql.SQLException;
import java.util.ArrayList;
import DB.BasicDao;
import user.UserVo;
public class UserDao extends BasicDao {
private final String MEMBER_LIST = "SELECT * FROM member";
private final String MEMBER_CHECK = "SELECT * FROM member WHERE id = ? and pw = ?";
private final String MEMBER_INSERT = "INSERT into member values(?,?,?,?,?,?,?)";
public ArrayList<UserVo> select() {
ArrayList list = new ArrayList();
try {
this.psmt = this.conn.prepareStatement("SELECT * FROM member");
this.rs = this.psmt.executeQuery();
while(this.rs.next()) {
UserVo member = new UserVo();
member.setId(this.rs.getString("ID"));
member.setName(this.rs.getString("NAME"));
member.setAddr(this.rs.getString("ADDR"));
member.setTel(this.rs.getString("TEL"));
member.setGender(this.rs.getString("GENDER"));
member.setHobby(this.rs.getString("HOBBY"));
list.add(member);
}
} catch (SQLException var3) {
var3.printStackTrace();
}
return list;
}
public UserVo selectUser(UserVo user) {
UserVo vo = null;
try {
this.psmt = this.conn.prepareStatement("SELECT * FROM member WHERE id = ? and pw = ?");
this.psmt.setString(1, user.getu_ID());
this.psmt.setString(2, user.getPw());
this.rs = this.psmt.executeQuery();
if (this.rs.next()) {
String id = this.rs.getString("id");
String pw = this.rs.getString("pw");
vo = new userVo(id, pw);
}
} catch (SQLException var5) {
var5.printStackTrace();
}
return vo;
}
public int memberInsert(MemberVo member) {
int n = 0;
try {
this.psmt = this.conn.prepareStatement("INSERT into member values(?,?,?,?,?,?,?)");
this.psmt.setString(1, member.getId());
this.psmt.setString(2, member.getName());
this.psmt.setString(3, member.getPw());
this.psmt.setString(4, member.getAddr());
this.psmt.setString(5, member.getTel());
this.psmt.setString(6, member.getGender());
this.psmt.setString(7, member.getHobby());
n = this.psmt.executeUpdate();
} catch (SQLException var4) {
var4.printStackTrace();
}
return n;
}
}

View File

@@ -1,5 +0,0 @@
package user;
public class UserVo {
}

View File

@@ -86,11 +86,11 @@
<th scope="row">성별</th>
<td>
<div class="custom-control custom-radio custom-control-inline">
<input class="custom-control-input" type="radio" id="male" name="u_gender" value="male" checked>
<input class="custom-control-input" type="radio" id="male" name="u_gender" value="남성" checked>
<label class="custom-control-label" for="male">남성</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input class="custom-control-input" type="radio" id="female" name="u_gender"value="female">
<input class="custom-control-input" type="radio" id="female" name="u_gender"value="여성">
<label class="custom-control-label" for="female">여성</label>
</div>
</td>

View File

@@ -24,9 +24,9 @@
<img class="mb-4" src="img/google_icon.png" alt="" width="100" height="100">
<h1 class="h3 mb-3 font-weight-normal">임직원 로그인</h1>
<label for="id" class="sr-only">Email address</label>
<input type="text" id="id" name="id" class="form-control" placeholder="ID" required autofocus>
<input type="text" id="u_ID" name="u_ID" class="form-control" placeholder="ID" required autofocus>
<label for="pw" class="sr-only">Password</label>
<input type="password" id="pw" name="pw" class="form-control" placeholder="Password" required>
<input type="password" id="u_psw" name="u_psw" class="form-control" placeholder="Password" required>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me

View File

@@ -0,0 +1,16 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="menu.jsp" />
<!DOCTYPE html>
<html>
<head>
<title>로그인 실패</title>
</head>
<body>
<div align="center">
<div><br/></div>
<div><h1>입력한 ${param.id}는 존재하지 않는 아이디 입니다.</h1></div>
<div><br/></div>
</div>
</body>
</html>
<jsp:include page="tail.jsp"/>

View File

@@ -0,0 +1,17 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="menu.jsp" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<!DOCTYPE html>
<html>
<head>
<title>로그인 성공</title>
</head>
<body>
<div align="center">
<div><h1>${requestScope.member.id} 님 환영합니다</h1></div>
<div><br/></div>
</div>
</body>
</html>
<jsp:include page="tail.jsp" />

View File

@@ -5,13 +5,13 @@
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<title>병원 종합 관리 시스템</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="home.do">김민구</a>
<a class="navbar-brand" href="home.do">병원 종합 관리 시스템</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
@@ -28,7 +28,7 @@
<a class="nav-link" href="boardList.do">자유게시판</a>
</li>
<li class="nav-item">
<a class="nav-link" href="memberJoin.do">회원가입</a>
<a class="nav-link" href="UserReg.do">회원가입</a>
</li>
<!--<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">