ASP

 

처리 과정

 

 

 

1. 회원가입 테이블 생성

-- usert 테이블 생성

create table usert(

	  number int identity(1,1) primary key,  -- 고유번호
		username nvarchar(100)  null  , -- 사용자 이름
		age int null,  -- 나이
	  sex nvarchar(5) null, --성별
    id1 nvarchar(50) , -- 아이디
    passwd nvarchar(50), -- 비밀번호
		email nvarchar(50), -- 이메일
		tel nvarchar(50), -- 전화번호
		address nvarchar(100), -- 주소
		date1 datetime  default GETDATE(),  -- 가입날짜
		visited int , -- 방문횟수
    point int -- 포인트


)

 

 

2. 테이블 이름 정의하기

countt  : 접속횟수

order_detrailt : 장바구니 및 주문 제품목록

order_sumt : 주문서 목록

prodt  :  제품 정보

sortt : 제품 분류

usert : 회원정보

count : "countt"

order_detailt ="order_detailt"

order_sumt ="order_sumt"

prodt ="prodt"

sortt ="sortt"

usert ="usert"

 

 

 

3. DB 연결 루틴 만들기(dbcon.asp)

dbcon.asp

<%

    Dim dbConnect, db '변수 선언'
    ' DB 연결 접속 정보 변수 저장
    dbConnect = "Provider=SQLOLEDB; Data Source=NITRO-PC\SQLEXPRESS;Initial Catalog=macaronics; User id=braverokmc;password=1111"
    ' 연결 객체 생성
    Set db = server.createObject("ADODB.Connection")
    ' 데이터베이스 접속
    db.open dbConnect


%>

 

 

Response 객체

<% Response.Buffer = True 혹은 Fasle  %>

True 로 지정하면 페이지 내용을 바로 보내지 않고 버퍼링을 한다. 이 내용은 HTML 페이지 상단에 명시한다. 이 버퍼링된 페이지를 

제어하기 위해서는 Flush,  Clear , End 메소드를 사용한다.  버퍼링된 페이지는 End 나 Flush 메소드의 명령을 받기 전까지는 페이지를

버퍼에 그대로 가지고 있다.

 

Response.Flush  :  Buffer 에 있는 결과를 즉시 보낸다. Response.Write 메소드를 사용한 출력 내용도 처리가 가능하다.

Response.Clear :  Buffer 에 있는 모든 HTML 결과를 지운다.

Response.End :  ASP  파일 처리를 멈추고 현재 결과값을 보낸다.

 

 

 

 

4. adduser.asp 전체 소스 코드 

header.asp

<%@Language="VBScript" CODEPAGE="65001" %>
<%
    ' 한글깨짐 방지 처리
   Response.CharSet="utf-8"
   Session.codepage="65001"
   Response.codepage="65001"
   Response.ContentType="text/html;charset=utf-8"

%>
<% response.buffer=true  %>
<!-- Buffer 프로퍼티를 이용한 페이지 버퍼링하기
Response.Buffer 프로퍼티를 사용하면 페이지를 버퍼링할 수 있다. 버퍼링이란 생성한 페이지를 바로
클라이언트로 전달하는 것이 아니라 서버에 보관한 다음 명령에 따라 보내거나 보내지 않게 하는 것이다.
버퍼링을 통해서 클라이언트에 보낼 페이지를 제어할 수 있다.
Response.Buffer = True 혹은 False
True 로 지정하면 페이지 내용을 바로 보내지 않고 버퍼링을 한다. 이 내용은 HTML 페이지 상단에 명시한다.
이 버퍼링된 페이지를 제어하기 위해서는 Flush,  Clear , End 메소드를 사용한다. 버퍼링된 페이지는 End 나
Flush 메소드의 명령을 받기 전까지는 페이지를 버퍼에 그대로 가지고 있다.

Response.Flush : Buffer 에 있는 결과를 즉시 보낸다. Response.Write 메소드를 사용한
출력 내용도 처리가 가능하다.

Respose.Clear : Buffer 에 있는 모든 HTML 결과를 지운다.
Response.End : ASP  파일 처리를 멈추고 현재 결과값을 보내다. -->

<html lang="ko">
<head>
<title>macaronics</title>
   <meta http-equiv="content-type" content="text/html"; charset="utf-8" >
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <!-- 위 3개의 메타 태그는 *반드시* head 태그의 처음에 와야합니다; 어떤 다른 콘텐츠들은 반드시 이 태그들 *다음에* 와야 합니다 -->
   <title>macaronics</title>
   <!-- 부트스트랩 -->
   <!-- 합쳐지고 최소화된 최신 CSS -->
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
   <!-- 부가적인 테마 -->
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
   <!-- 합쳐지고 최소화된 최신 자바스크립트 -->
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
   <!-- IE8 에서 HTML5 요소와 미디어 쿼리를 위한 HTML5 shim 와 Respond.js -->
   <!-- WARNING: Respond.js 는 당신이 file:// 을 통해 페이지를 볼 때는 동작하지 않습니다. -->
   <!--[if lt IE 9]>
     <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
   <![endif]-->
   <!-- Bootstrap core JavaScript
   ================================================== -->
   <!-- Placed at the end of the document so the pages load faster -->
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>


<style>
#header_menu, #navbar, .navbar navbar-inverse navbar-static-top{
background:#EE7785;
color: white;
}
#header_menu .navbar-header{
  color: white;
}
.navbar-inverse .navbar-brand{
  background:#EE7785;
}

.navbar-inverse .navbar-nav>li>a{
  color:white;
}
.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.open>a{
  background:#337AB7;
}

#navbar .navbar-nav>li>a:hover, #navbar  .navbar-nav>li>a:hover{
  background:#337AB7;
}


#footer {
   position:fixed;
   left:0px;
   bottom:0px;
   height:60px;
   width:100%;
   background:#EE7785;
   color: white;

}
#footer  p {

   text-align: center;
   vertical-align: middle;
}
</style>

 

 

 

 

adduser.asp

<!--#include  virtual=./mall/include/header.asp -->
<script>
$(document).ready(function() {

    $("#btnRegist").click(function(e){
          var form =document.form1;

          if(form.id1.value.length==0){
            alert("ID를 입력하세요.");
            form.id1.focus();
            return false;
          }

          if(form.passwd.value.length==0){
            alert("비밀번호를 입력하세요.");
            form.passwd.focus();
            return false;
          }

          if(form.username.value.length==0){
            alert("이름을 입력하세요.");
            form.username.focus();
            return false;
          }

          if(form.email.value.length==0){
            alert("이메일을 입력하세요.");
            form.email.focus();
            return false;
          }

          if(form.tel.value.length==0){
            alert("전화번호를 입력하세요.");
            form.tel.focus();
            return false;
          }

          if(form.address.value.length==0){
            alert("주소를 입력하세요.");
            form.address.focus();
            return false;
          }

          if(form.age.value.length==0){
            alert("나이를 입력하세요.");
            form.age.focus();
            return false;
          }

          if(form.sex.value.length==0){
            alert("성별을 입력하세요.");
            form.sex.focus();
            return false;
          }

          form.submit();
    });


});

</script>
</header>
<body>
<%
    Dim id1, passwd, username, email, tel, address, age, sex
    id1=request("id1")
    passwd=request("passwd")
    username=request("username")
    email=request("email")
    tel=request("tel")
    address=request("address")
    age=request("age")
    sex=request("sex")


    id=request("id")
    if id="error" then
%>
<script>alert("중복된 아이디 입니다.")</script>
<%
    end if
%>
<!--#include virtual="./mall/include/header_menu.asp" -->

<div class="rows">
<div class="container">

   <div clss="col-xs-12 col-sm-12">
      <h1 class="bg-primary text-center" style="width:100%; padding-top:20px; padding-bottom:20px; text-align:center">회원등록</h1>
      <div class="col-xs-3 col-sm-3"></div>
     <div class="col-xs-6 col-sm-6">

        <p>&nbsp;</p>
        <p class="text-center">
          <span style="color:red;">* 아래 항목을 빠짐 없이 입력해 주세요.</span>
        </p>
       <form method="post" action="adduserOk.asp" name="form1" >
         <table class="table table-striped" >
            <tr>
              <th>등록할 회원 ID </th>
              <td><input type="text" value=""  class="form-control"  name="id1"/></td>
            </tr>

            <tr>
              <th>등록할 비빌번호 </th>
              <td><input type="password" value=""  class="form-control" name="passwd" /></td>
            </tr>

            <tr>
              <th>이름 </th>
              <td><input type="text" value="<%=username %>"  class="form-control" name="username" /></td>
            </tr>

            <tr>
              <th>Email  </th>
              <td><input type="email" value="<%=email %>"  class="form-control" name="email" /></td>
            </tr>

            <tr>
              <th>연락처 </th>
              <td><input type="tel" value="<%=tel %>"  class="form-control" name="tel" /></td>
            </tr>


            <tr>
              <th>현주소 </th>
              <td><input type="text" value="<%=address %>"  class="form-control"  name="address" /></td>
            </tr>


            <tr>
              <th>나이 </th>
              <td><input type="number" max="100" min="1" class="form-control"  name="age" value="<%=age %>" /></td>
            </tr>


            <tr>
              <th>성별 </th>
              <td>
                  <select name="sex" class="form-control">
                      <option value="남" <% if sex="남" then response.write "selected" end if %> >남</option>
                      <option value="여"  <% if sex="여" then response.write "selected"  end if %> >여</option>
                  </select>
              </td>
            </tr>

            <tr class="text-center">
              <td colspan="2">
                <button type="button" class="btn-success" id="btnRegist">신규회원 등록 </button>
                <button type="button"  class="btn-primary">로그인 </button>
                <button type="button" class="btn-danger">닫기</button>
              </td>
            </tr>
         </table>
     </form>

     </div>
   </div>


</div>
</div>



<!--#include  virtual=./mall/include/footer.asp -->

 

 

footer.asp

<p class="margin-top:200px"></p>
<div class="rows">
<div class="col-xs-3 col-sm-3"  ></div>
  <div class="col-xs-6 col-sm-6">

<!-- FOOTER -->
   <footer  id="footer">
     <p>&nbsp;</p>
     <p>&copy; 2018 macaronics - Junho Choi</p>
      <p>&nbsp;</p>
   </footer>
</div><!-- /.container -->
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://bootstrapk.com/dist/js/bootstrap.min.js"></script>

</body>
</html>

 

 

adduserOk.asp

<!--#include  virtual=./mall/include/header.asp -->
</header>
<body>
<!--#include virtual="./mall/dbcon.asp" -->
<%
  Dim id1, passwd, username, email, tel, address, age, sex
  id1=request.form("id1")
  passwd=request.form("passwd")
  username=request.form("username")
  email=request.form("email")
  tel=request.form("tel")
  address=request.form("address")
  age=request.form("age")
  sex=request.form("sex")

  usert="usert"
  nowdate=now
  nowdate=left(nowdate, 19)
  visited=0
  point=0

%>
<form name="form2" action="adduser.asp" method="post">
<input type="hidden" name="id" value="error" />
<input type="hidden" name="username" value="<%= username %>" />
<input type="hidden" name="email" value="<%= email %>" />
<input type="hidden" name="tel" value="<%= tel %>" />
<input type="hidden" name="address" value="<%= address %>" />
<input type="hidden" name="age" value="<%= age %>" />
<input type="hidden" name="sex" value="<%= sex%>" />
</form>

<%
  'Response.Write " 결과 :  " &id1&" , "& passwd &" , "& username &" , "& email &" , "& tel &" , "& address &" , "& age &" , "& sex
%>
<%

  sql1="select * from " & usert & " where id1='"&id1&"'"
  Set rs1=db.Execute(sql1)

  if rs1.EOF then

    sql2 ="insert into "& usert
    sql2 =sql2 &" (id1, passwd, username, email, tel, address, age, sex,  visited, point) values ('"
    sql2 =sql2 & id1 &"', '"& passwd &"', '"& username &"', '"& email &"', '"& tel &"', '"&  address &"', '"&  age &"', '"&  sex &"', '"& visited &"', '"& point &"' )"
    'Response.write sql2
    Set rs2 =db.execute(sql2)

    'Response.write "등록되었습니다."
%>


<!--#include virtual="./mall/include/header_menu.asp" -->
<div class="rows">
<div class="container">

   <div clss="col-xs-12 col-sm-12">
      <h1 class="bg-primary text-center" style="width:100%; padding-top:20px; padding-bottom:20px; text-align:center">가입을 축하합니다.</h1>
      <div class="col-xs-3 col-sm-3"></div>
     <div class="col-xs-6 col-sm-6">

<table class="table table-striped" >
  <caption class="text-center">
    <h3>등록 내용</h3>
  </caption>
   <tr>
     <th>등록할 회원 ID :</th>
     <td><%= id1 %></td>
   </tr>

   <tr>
     <th>등록할 비빌번호 :</th>
     <td><%= passwd %></td>
   </tr>

   <tr>
     <th>이름 :</th>
     <td><%= username %></td>
   </tr>

   <tr>
     <th>Email : </th>
     <td><%= email %> </td>
   </tr>

   <tr>
     <th>연락처 :</th>
     <td><%= tel %> </td>
   </tr>


   <tr>
     <th>현주소 :</th>
     <td><%= address %></td>
   </tr>

   <tr>
     <th>나이  :</th>
     <td><%= age  %></td>
   </tr>


   <tr>
     <th>성별 :</th>
     <td> <%= sex %>
     </td>
   </tr>
</table>

<%
  else

    '"중복된 아이디 입니다."
%>
<script>
 document.form2.submit();
</script>

<%
     response.end
  end if
%>


    </div>
    </div>
</div>
</div>



</body>
</html>

 

 

 

제작  소스 - Junho  choi  - macaronics  : https://github.com/braverokmc79/asp-shoppingMall

 

 

 

 

 

 

 

 

about author

PHRASE

Level 60  라이트

범을 그리면서 가죽을 그릴 수 있으나 뼈는 그리기 어렵다. 사람을 알아 얼굴을 알 수 있어도 그 마음은 알지 못한다. -명심보감

댓글 ( 4)

댓글 남기기

작성