ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 211025-211029_mini project(insert)
    카테고리 없음 2021. 10. 27. 08:55

    memberform.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"

        pageEncoding="UTF-8"%>

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="UTF-8">

    <link href="https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap" rel="stylesheet">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

    <script src="https://code.jquery.com/jquery-3.5.0.js"></script>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

    <title>회원가입</title>

     

    <script type="text/javascript">

    $(function() {

     

    //이메일 선택 이벤트

    $("#selemail").change(function() {

    if($(this).val()=='-'){

    $("#email2").val('');  //지정된 메일 지우기

    $("#email2").focus();  //포커스 주기

    } else {

    $("#email2").val($(this).val());

    }

    });

     

    //아이디 입력버튼 이벤트

    $("#btnidcheck").click(function() {

    window.open("member/idsearch.jsp","","width=600px,height=200px,left=500px,top=100px");

    });

    });

     

    //check

    function check(f) {

     

    //아이디 입력 안 했을 경우

    if(f.id.value.length==0){

    alert("아이디 입력해주세요");

    return false;

    }

     

    if(f.pass.value!=f.pass2.value){

    alert("비밀번호가 틀립니다");

    f.pass.value="";  //초기화

    f.pass2.value="";

    return false;  //액션 호출 안 되는 거.. return true는 액션 호출 되는 거

    }

    }

    </script>

     

    </head>

    <body>

    <form action="member/memberadd.jsp" method="post" class="form-inline"

    name="memberfrm" onsubmit="return check(this)">

      <table class="table table-bordered" style="width: 500px;">

        <caption><b>회원가입</b></caption>

        <tr>

          <th width="100" bgcolor="#fffacd">아이디</th>

          <td>

            <input type="text" name="id" maxlength="8" class="form-control"

             required="required" style="width: 120px;" readonly="readonly">

            <button type="button" class="btn btn-danger btn-sm" id="btnidcheck">아이디입력</button>

          </td>

        </tr>

        

        <tr>

          <th width="100" bgcolor="#fffacd">비밀번호</th>

          <td>

            <input type="password" name="pass" class="form-control"

             required="required" style="width: 120px;" placeholder="비밀번호">

             

             <input type="password" name="pass2" class="form-control"

             required="required" style="width: 120px;" placeholder="비밀번호확인">

          </td>

        </tr>

        

        <tr>

          <th width="100" bgcolor="#fffacd">이름</th>

          <td>

            <input type="text" name="name" class="form-control"

             required="required" style="width: 120px;">

          </td>

         </tr> 

         

         <tr>

          <th width="100" bgcolor="#fffacd">연락처</th>

          <td>

            <input type="text" name="hp" class="form-control"

             required="required" style="width: 200px;">

          </td>

         </tr> 

         

         <tr>

          <th width="100" bgcolor="#fffacd">주소</th>

          <td>

            <input type="text" name="addr" class="form-control"

             required="required" style="width: 400px;">

          </td>

         </tr>

         

         <tr>

          <th width="100" bgcolor="#fffacd">이메일</th>

          <td>

            <input type="text" name="email1" class="form-control"

             required="required" style="width: 80px;">

             <b>@</b>

             <input type="text" name="email2" class="form-control"

             required="required" style="width: 120px;" id="email2">

             

             <select id="selemail" class="form-control">

              <option value="-">직접입력</option>

              <option value="naver.com">네이버</option>

              <option value="google.com">구글</option>

              <option value="hanmail.net">다음</option>

             </select>

          </td>

         </tr>

         

         <tr>

           <td align="center" colspan="2">

             <button type="submit" class="btn btn-default" style="width: 100px;">저장</button>

             <button type="reset" class="btn btn-default" style="width: 100px;">다시</button>

           </td>

         </tr>

      </table>

    </form>

    </body>

    </html>

     

     

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     

     

    memberadd.jsp

    <%@page import="data.dao.MemberDao"%>

    <%@page import="data.dto.MemberDto"%>

    <%@ page language="java" contentType="text/html; charset=UTF-8"

        pageEncoding="UTF-8"%>

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="UTF-8">

    <link href="https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap" rel="stylesheet">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

    <script src="https://code.jquery.com/jquery-3.5.0.js"></script>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

    <title>Insert title here</title>

    </head>

    <body>

    <%

    //action처리하는 곳

    //dao에서 insert만들고 여기서 처리

    //success페이지 나오면서 가입축하..님의 가입을 축하합니다

     

    //한글 엔코딩

    request.setCharacterEncoding("utf-8");

     

    //데이터 읽어서 dto 담기

    MemberDto dto=new MemberDto();

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

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

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

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

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

    String email=request.getParameter("email1")+"@"+request.getParameter("email2");

     

    dto.setName(name);

    dto.setId(id);

    dto.setPass(pass);

    dto.setHp(hp);

    dto.setAddr(addr);

    dto.setEmail(email);

     

    //dao 선언후 insert메서드 호출

    MemberDao dao=new MemberDao();

    dao.insertMember(dto);

     

    //index를 거친 다음 gaipsuccess로 이동하고 id 넘기기(저쪽 가입에서 ~님 가입 축하합니다 하기위해 id 받음)

    //memberadd는 member안에 있기에 폴더 하나를 올라가야 한다..앞으로 액션폼은 다 ../ 통해서 

    response.sendRedirect("../index.jsp?main=member/gaipsuccess.jsp?id="+id);

    %>

    </body>

    </html>

     

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     

     

    gaipsuccess.jsp

    <%@page import="data.dao.MemberDao"%>

    <%@ page language="java" contentType="text/html; charset=UTF-8"

        pageEncoding="UTF-8"%>

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="UTF-8">

    <link href="https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap" rel="stylesheet">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

    <script src="https://code.jquery.com/jquery-3.5.0.js"></script>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

    <title>Insert title here</title>

    </head>

    <body>

    <%

    //id를 읽는다

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

    //여기서 id대신 name을 받으면 출력시 한글깨짐현상이 생김

     

    /* id값만 나타내려면 필요없음

    //dao 선언

    MemberDao dao=new MemberDao();

     

    //아이디에 대한 이름 가져오기

    String name=dao.getName(id); */

    %>

     

    <div style="margin: 0 auto; width: 100%;">

      <img alt="" src="image/monster.png">

      <%-- <b><%=name %>님의 회원가입을 축하합니다</b>..id값만 나타내려면 필요없음 --%>

      <b><%=id %>님의 회원가입을 축하합니다</b>

      <br><br>

      

      <button type="button" class="btn btn-info" onclick="loaction.href='index.jsp?'">로그인</button>

      <button type="button" class="btn btn-info" onclick="loaction.href='index.jsp'">Home</button>

      <button type="button" class="btn btn-info" onclick="loaction.href='index.jsp?main=member/memberlist.jsp'">회원명단</button>

    </div>

    </body>

    </html>

    댓글

Designed by Tistory.