主要代碼:
<% Response.ContentType="text/vnd.wap.wml" %>
<?XML version="1.0" encoding="gb2312"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd" >
<wml>
<card id="SJ" title="手機號碼所在地查詢">
<%
' 數據庫連接
dim connstr1,conn1
const DB="xxx.mdb" '手機庫路徑
connstr1="DBQ="+server.mappath(""&DB&"")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn1=server.createobject("ADODB.CONNECTION")
conn1.open connstr1
'過濾非法字符
function chk(str)
if str<>"" then
chktopic=replace(str,"'","''")
end if
end function
%>
<%
'手機查詢
if request.form("SJ")<>"" then
d= chk(request.form("SJ"))
'判斷是否為數字或者大於7位的數字
if len(d)>=7 and IsNumeric(d) then
c=left(d,7)
'這裡省略了很多代碼
sql="select * from mod where start<="&c&" and end>="&c&" and mid(start,3,1)="&mid(c,3,1)&" and mid(end,3,1)="&mid(c,3,1)&" and mid(start,4,1)="&mid(c,4,1)&" and mid(end,4,1)="&mid(c,4,1)&" and mid(start,5,1)="&mid(c,5,1)&" and mid(end,5,1)="&mid(c,5,1)&" and mid(start,6,1)="&mid(c,6,1)&" and mid(end,6,1)="&mid(c,6,1)&" "
set rs=conn1.execute(sql)
if not rs.eof then
a=rs("city")
b=rs("city1")
e=rs("url")
f=rs("thank")
set rs=nothing
else
a="對不起,沒有找到這個號碼的紀錄"
end if
else
a="錯誤:請確保你輸入的是大於7位的數字!"
end if
%>
<b>您搜索的手機號碼:</b><br/>
<%=d%><br/>
<b>所在地址:</b><%=a%> <%=b%><br/>
<b>區號和描述:</b><br/>
<%=e%> <%=f%>
<br/><br/>
<%end if%>
請輸入手機號碼
<input size="8" name="SJ" type="text" maxlength="11" />
<anchor title="確定">確定
<go href="index.ASP" method="post">
<postfIEld name="SJ" value="$SJ"/>
</go>
</anchor>
<p align="center"><b>Hikey.Net</b></p>
</card>
</wml>
<%
set conn1=nothing
%>