ClassicASP 우편번호 검색 삽입하기
페이지 정보
첨부파일
-
img.zip (7.4K)
20회 다운로드 | DATE : 2010-03-24 19:38:38
본문
##### write.asp #####
<script type="text/javascript">
<!--
function zipfind(url, field) {
var opt = "toolbar=no, resizable=yes, scrollbars=yes, location=no, resize=no,menubar=no, directories=no, copyhistory=0, width=450, height=250, top=330, left=370";
window.open(url, 'new_window', opt);
}
//-->
</script>
<form id="fregisterform" name="fregisterform" method="post" onSubmit="return fregisterform_submit(this);" enctype="multipart/form-data">
<input type="tex"t name='zip1' size="4" maxlength="3" itemname='우편번호 앞자리' value='<% 'response.write mb_zip1 %>'> -
<input type="text" name='zip2' size="4" maxlength="3" itemname='우편번호 뒷자리' value='<% 'response.write mb_zip2 %>'>
<a href="javascript:zipfind('zipcode.asp', this);"><img width="91" height="20" src="../img/post_search_btn.gif" border=0 align="absmiddle"></a>
<input type="text" name='add1' size=60 itemname='주소' value='<% 'response.write mb_addr1 %>'>
<input type="text" name='add2' size=60 itemname='상세주소' value='<% 'response.write mb_addr2 %>'></td>
</form>
##### dbconfig.asp #####
<%
dim conn1, db
conn1="provider=sqloledb; server=디비주소; Database=디비네임; UID=디비아이디; PWD=디비비밀번호;" Set Db = Server.CreateObject("ADODB.Connection")
db.open conn1
%>
#### function.asp ####
<%
' 인젝션 방지관련 https://www.happyjung.com/lecture/480
'function sqlCheck(str)
'...
'end function
%>
##### zipcode.asp #####
<!--#include file="function.asp" -->
<!--#include file="dbconfig.asp" -->
<%
dim ErrNum, MSG
dim TDStyle, str_zip, ErrFlag, i
dim tmp, tmp_zip, tmp_zip1, tmp_zip2
ErrNum = sqlCheck(Trim(Request("ErrNum")))
IF ErrNum <> "" Then
Select Case ErrNum
Case "0011"
MSG = "<font color=red>해당 검색어에 해당하는 우편번호가 존재하지 않습니다. <br> 다시 검색하여 주십시오! </font><br><br>"
End Select
End IF
TDStyle = "border-bottom: black 1px solid; border-left: black 1px solid; border-right: black 1px solid; border-top: black 1px solid; "
str_zip = sqlCheck(Trim(Request("str_zip")))
IF len(str_zip) >= 2 then
SQL="SELECT zipCode,siDo,gugun,dong,bunji from dg_zipcode Where dong like '%"& str_zip &"%'"
Set Rs=conn.Execute(SQL)
IF Rs.EOF Then
ErrFlag = True
ErrNum = 0011
Response.Redirect "zipcode.asp?ErrNum=0011"
Response.End
End IF
End IF
%>
<html>
<head>
<title>우편번호 찾기</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
body { margin: 0; font-size:12px; overflow: hidden; overflow-x: hidden; overflow-y: scroll; }
td { font-size:12px; }
a:link { font-family:"돋움"; text-decoration:none; color:#000000; line-height: 18px;}
a:active { font-family:"돋움"; text-decoration:none; color:#000000; line-height: 18px;}
a:visited { font-family:"돋움"; text-decoration:none; color:#000000; line-height: 18px;}
a:hover { font-family:"돋움"; text-decoration:underline; color:#000000; line-height: 18px;}
</style>
<script language="javascript">
<!--
function GoSearch() {
fom = document.forms[0];
if ( document.InSearch.str_zip.value == "" ) {
alert("기재하고 싶은 주소를 선택하세요!");
fom.str_zip.focus();
return;
}
if (document.InSearch.str_zip.value.length <= 1) {
alert("주소입력은 2자리 이상이어야 합니다!");
fom.str_zip.focus();
return;
}
document.InSearch.submit();
}
//-->
</script>
<script type="text/javascript">
<!--
function copy(tmp_zip1, tmp_zip2, c) {
opener.fregisterform.zip1.value = tmp_zip1;
opener.fregisterform.zip2.value = tmp_zip2;
opener.fregisterform.add1.value = c;
opener.fregisterform.add2.focus();
window.close();
}
//-->
</script>
</head>
<body>
<TABLE cellSpacing=0 cellpadding="2" style="BORDER-COLLAPSE: collapse" width="97%">
<%
if len(str_zip) >= 2 then
i = 0
Do While Not Rs.EOF
'response.write rs("zipcode")
tmp_zip = rs("zipcode")
tmp = split(tmp_zip,"-")
tmp_zip1 = tmp(0)
tmp_zip2 = tmp(1)
%>
<tr height="20" onmouseover="this.style.backgroundcolor='#EFEFEF'" onmouseout="this.style.backgroundcolor='#FFFFFF'">
<td height="30" style="<%=TDStyle%>">
<a href="#" onclick="copy('<%
response.write tmp_zip1 %>','<% response.write tmp_zip2 %>','<%
response.write rs("sido") &" "
response.write rs("gugun") &" "
response.write rs("dong") &" "
%>')">
<%
response.write "["& tmp_zip1 &"-"& tmp_zip2 &"] "
response.write rs("sido") &" "
response.write rs("gugun") &" "
response.write rs("dong") &" "
response.write rs("bunji")
%></a></td>
</tr>
<%
Rs.MoveNext
i = i + 1
Loop
conn.Close
Set conn = Nothing
end if
%>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="../img/member/zipcode_top.gif" /></td>
</tr>
<tr>
<td background="../img/member/zipcode_middle.gif" style="padding-top:10px;">
<form name="InSearch" method="post" action="zipcode.asp">
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<input name="str_zip" class="input_box">
<img src="../img/member/zipcode_submit.gif" align="absmiddle" onclick="GoSearch();" /></td>
</tr>
</table>
</form>
<%= MSG %>
<table width="400" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td style="padding-top:10px;">
검색창에서 읍, 면, 동 이름중 한가지만 입력하십시요.<br />
</td>
</tr>
<tr align="center">
<td colspan="2"><img src="../img/member/zipcode_close.gif" onclick="self.close();"border="0" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="../img/member/zipcode_bottom.gif" /></td>
</tr>
</table>
</body>
</html>
참고사이트
http://postman.pe.kr
http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=1040204&docId=65474781
<script type="text/javascript">
<!--
function zipfind(url, field) {
var opt = "toolbar=no, resizable=yes, scrollbars=yes, location=no, resize=no,menubar=no, directories=no, copyhistory=0, width=450, height=250, top=330, left=370";
window.open(url, 'new_window', opt);
}
//-->
</script>
<form id="fregisterform" name="fregisterform" method="post" onSubmit="return fregisterform_submit(this);" enctype="multipart/form-data">
<input type="tex"t name='zip1' size="4" maxlength="3" itemname='우편번호 앞자리' value='<% 'response.write mb_zip1 %>'> -
<input type="text" name='zip2' size="4" maxlength="3" itemname='우편번호 뒷자리' value='<% 'response.write mb_zip2 %>'>
<a href="javascript:zipfind('zipcode.asp', this);"><img width="91" height="20" src="../img/post_search_btn.gif" border=0 align="absmiddle"></a>
<input type="text" name='add1' size=60 itemname='주소' value='<% 'response.write mb_addr1 %>'>
<input type="text" name='add2' size=60 itemname='상세주소' value='<% 'response.write mb_addr2 %>'></td>
</form>
##### dbconfig.asp #####
<%
dim conn1, db
conn1="provider=sqloledb; server=디비주소; Database=디비네임; UID=디비아이디; PWD=디비비밀번호;" Set Db = Server.CreateObject("ADODB.Connection")
db.open conn1
%>
#### function.asp ####
<%
' 인젝션 방지관련 https://www.happyjung.com/lecture/480
'function sqlCheck(str)
'...
'end function
%>
##### zipcode.asp #####
<!--#include file="function.asp" -->
<!--#include file="dbconfig.asp" -->
<%
dim ErrNum, MSG
dim TDStyle, str_zip, ErrFlag, i
dim tmp, tmp_zip, tmp_zip1, tmp_zip2
ErrNum = sqlCheck(Trim(Request("ErrNum")))
IF ErrNum <> "" Then
Select Case ErrNum
Case "0011"
MSG = "<font color=red>해당 검색어에 해당하는 우편번호가 존재하지 않습니다. <br> 다시 검색하여 주십시오! </font><br><br>"
End Select
End IF
TDStyle = "border-bottom: black 1px solid; border-left: black 1px solid; border-right: black 1px solid; border-top: black 1px solid; "
str_zip = sqlCheck(Trim(Request("str_zip")))
IF len(str_zip) >= 2 then
SQL="SELECT zipCode,siDo,gugun,dong,bunji from dg_zipcode Where dong like '%"& str_zip &"%'"
Set Rs=conn.Execute(SQL)
IF Rs.EOF Then
ErrFlag = True
ErrNum = 0011
Response.Redirect "zipcode.asp?ErrNum=0011"
Response.End
End IF
End IF
%>
<html>
<head>
<title>우편번호 찾기</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
body { margin: 0; font-size:12px; overflow: hidden; overflow-x: hidden; overflow-y: scroll; }
td { font-size:12px; }
a:link { font-family:"돋움"; text-decoration:none; color:#000000; line-height: 18px;}
a:active { font-family:"돋움"; text-decoration:none; color:#000000; line-height: 18px;}
a:visited { font-family:"돋움"; text-decoration:none; color:#000000; line-height: 18px;}
a:hover { font-family:"돋움"; text-decoration:underline; color:#000000; line-height: 18px;}
</style>
<script language="javascript">
<!--
function GoSearch() {
fom = document.forms[0];
if ( document.InSearch.str_zip.value == "" ) {
alert("기재하고 싶은 주소를 선택하세요!");
fom.str_zip.focus();
return;
}
if (document.InSearch.str_zip.value.length <= 1) {
alert("주소입력은 2자리 이상이어야 합니다!");
fom.str_zip.focus();
return;
}
document.InSearch.submit();
}
//-->
</script>
<script type="text/javascript">
<!--
function copy(tmp_zip1, tmp_zip2, c) {
opener.fregisterform.zip1.value = tmp_zip1;
opener.fregisterform.zip2.value = tmp_zip2;
opener.fregisterform.add1.value = c;
opener.fregisterform.add2.focus();
window.close();
}
//-->
</script>
</head>
<body>
<TABLE cellSpacing=0 cellpadding="2" style="BORDER-COLLAPSE: collapse" width="97%">
<%
if len(str_zip) >= 2 then
i = 0
Do While Not Rs.EOF
'response.write rs("zipcode")
tmp_zip = rs("zipcode")
tmp = split(tmp_zip,"-")
tmp_zip1 = tmp(0)
tmp_zip2 = tmp(1)
%>
<tr height="20" onmouseover="this.style.backgroundcolor='#EFEFEF'" onmouseout="this.style.backgroundcolor='#FFFFFF'">
<td height="30" style="<%=TDStyle%>">
<a href="#" onclick="copy('<%
response.write tmp_zip1 %>','<% response.write tmp_zip2 %>','<%
response.write rs("sido") &" "
response.write rs("gugun") &" "
response.write rs("dong") &" "
%>')">
<%
response.write "["& tmp_zip1 &"-"& tmp_zip2 &"] "
response.write rs("sido") &" "
response.write rs("gugun") &" "
response.write rs("dong") &" "
response.write rs("bunji")
%></a></td>
</tr>
<%
Rs.MoveNext
i = i + 1
Loop
conn.Close
Set conn = Nothing
end if
%>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="../img/member/zipcode_top.gif" /></td>
</tr>
<tr>
<td background="../img/member/zipcode_middle.gif" style="padding-top:10px;">
<form name="InSearch" method="post" action="zipcode.asp">
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<input name="str_zip" class="input_box">
<img src="../img/member/zipcode_submit.gif" align="absmiddle" onclick="GoSearch();" /></td>
</tr>
</table>
</form>
<%= MSG %>
<table width="400" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td style="padding-top:10px;">
검색창에서 읍, 면, 동 이름중 한가지만 입력하십시요.<br />
</td>
</tr>
<tr align="center">
<td colspan="2"><img src="../img/member/zipcode_close.gif" onclick="self.close();"border="0" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="../img/member/zipcode_bottom.gif" /></td>
</tr>
</table>
</body>
</html>
참고사이트
http://postman.pe.kr
http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=1040204&docId=65474781
댓글목록
등록된 댓글이 없습니다.