01.asp
来自「1.理解Winsock编程模型; 2.掌握Winsock编程的基本方法」· ASP 代码 · 共 276 行
ASP
276 行
<%
if session("uname")="" then
%>
<script language="javascript">
if (confirm("您进行的是非法登录,请重新登录!"))
location.href="admin.asp";
</script>
<%
end if
%>
<!--#include file = conn.asp -->
<!--#include file = titleb.asp -->
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<STYLE type="text/css"> <!-- a:link { text-decoration: none; font-family: AdobeSm; color: #000000 }
a:visited { text-decoration: none; color: #000000 }
A:hover {COLOR: green; FONT-FAMILY: "宋体"; TEXT-DECORATION: underline;}
body { font-size: 9pt; font-family: 宋体, Arial;color: #000000}
TD {FONT-SIZE: 9pt; FONT-FAMILY: "宋体", "Arial";color: #000000}
p {FONT-SIZE: 9pt; FONT-FAMILY: "宋体", "Arial";color: #000000}
input {FONT-SIZE: 9pt; FONT-FAMILY: "宋体", "Arial";color: #000000}
body { margin-top: 0; margin-bottom: 0; color: #000000 }
--></STYLE>
<script language="JavaScript">
<!--
function FP_jumpMenu(el,frm,sel) {//v1.0
var href=el.options[el.selectedIndex].value; if(sel) el.selectedIndex=0;
if('_new'==frm) open(href); else eval(frm+".location='"+href+"'");
}
// -->
</script>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<br>
<div align="center"></div>
<div align="center">
<%
action=request("action")
id=request("id")
if action="删除" then
set rs = server.createobject("adodb.recordset")
sql = "select * from admin where id="&id
rs.open sql,conn,3,2
rs.delete
rs.update
rs.close
set rs=nothing
%>
<script language="javascript">
if (confirm("用户删除成功!"))
location.href="01.asp";
</script>
<%
end if
id1=request("id1")
ok=request("ok")
uname=trim(request("uname"))
password=trim(request("password"))
gl=request("gl")
if ok="ok" then
if uname="" then
%>
<script language="javascript">
if (confirm("用户名不能为空!"))
location.href="01.asp";
</script>
<%
elseif password="" then
%>
<script language="javascript">
if (confirm("密码不能为空!"))
location.href="01.asp";
</script>
<%
else
set rs = server.createobject("adodb.recordset")
sql = "select * from admin where uname='"&uname&"' and password='"&password&"'"
rs.open sql,conn,3,2
if rs.eof then
rs.addnew
rs("uname")=uname
rs("password")=password
rs("gl")=gl
rs("pubdate")=now()
rs.update
rs.close
set rs=nothing
%>
<script language="javascript">
if (confirm("用户添加成功!"))
location.href="01.asp";
</script>
<%
end if
end if
elseif ok="no" then
set rs = server.createobject("adodb.recordset")
sql = "select * from admin where id="&id1
rs.open sql,conn,3,2
rs("uname")=uname
rs("password")=password
rs("gl")=gl
rs("pubdate")=now()
rs.update
rs.close
set rs=nothing
%>
<script language="javascript">
if (confirm("用户信息修改成功!"))
location.href="01.asp";
</script>
<%
else
%>
<table border="1" width="750" id="table1" cellspacing="0" cellpadding="3" style="border-collapse: collapse" bordercolor="#C0C0C0">
<tr>
<td width="318" align="center" bgcolor="#F5F5F5" background="images/topBar_bg.gif"><b>用户名</b></td>
<td width="156" align="center" bgcolor="#F5F5F5" background="images/topBar_bg.gif"><b>加入时间</b></td>
<td colspan="2" align="center" background="images/topBar_bg.gif" bgcolor="#F5F5F5"><b>操作</b></td>
</tr>
<%
sql = "select * from admin"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,1
if rs.recordcount<>0 then
page=int(request.QueryString ("page"))
rs.PageSize=20
pagecount=rs.pagesize
if page<=0 then page=1
if request.QueryString("page")="" then page=1
rs.AbsolutePage=page
gg=rs.recordcount/pagecount
gh=int(gg)
if gh<=1 then gh=1
if gg>gh then gh=gh+1
gg=gh
for i=1 to pagecount
%>
<tr>
<td width="318"><DIV align="center">(<%=rs("uname")%>)</DIV></td>
<td width="156" align="center"><%=rs("pubdate")%></td>
<td><%=rs("gl")%></td>
<td><a href="01.asp?action=修改&id=<%=rs("id")%>">修改</a> <a onclick='{if(confirm("您确定删除吗?此操作将不能恢复!")){return true;}return false;}' href="01.asp?action=%C9%BE%B3%FD&id=<%=rs("id")%>">删除</a>
</td>
</tr>
<%
rs.movenext
if rs.eof then exit for
next
else
Response.Write "<tr><td colspan=4>暂无信息</td></tr>"
end if
%>
</table>
</div>
<center><br>
<%
if rs.recordcount<>0 then
if page>1 then%>
<a href='<%=request.servervariables("URL")%>?page=1&title=<%=title%>&lm=<%=lm%>'>首页</a>
<a href='<%=request.servervariables("URL")%>?page=<%=page-1%>&title=<%=title%>&lm=<%=lm%>'>上一页</a>
<%end if%>
<%if page<gg then%>
<a href='<%=request.servervariables("URL")%>?page=<%=page+1%>&title=<%=title%>&lm=<%=lm%>'>下一页</a>
<a href='<%=request.servervariables("URL")%>?page=<%=rs.pagecount%>&title=<%=title%>&lm=<%=lm%>'>尾页</a>
<%end if%>
共<%=rs.recordcount%>条 每页显示<%=pagecount%>条 第<%=page%>页 共<%=rs.pagecount%>页
<script language="JavaScript">
<!--
function FP_jumpMenu(el,frm,sel) {//v1.0
var href=el.options[el.selectedIndex].value; if(sel) el.selectedIndex=0;
if('_new'==frm) open(href); else eval(frm+".location='"+href+"'");
}
// -->
</script>
<select size="1" onchange="FP_jumpMenu(this,'window',false)" id="id1" name="D1" style="font-size: 9pt; border-style: solid; border-width: 1px">
<%for i=1 to rs.pagecount%>
<option value="<%=request.servervariables("URL")%>?page=<%=i%>&title=<%=title%>&lm=<%=lm%>" <%if page=i then response.write "selected"%>>第<%=i%>页</option>
<%next%>
</select></p>
<%end if
if action="修改" then
set rs1 = server.createobject("adodb.recordset")
sql1 = "select * from admin where id="&id
rs1.open sql1,conn,3,2
%>
<table width="350" border="1" cellspacing="2" cellpadding="2">
<form name="form1" method="post" action="">
<tr>
<td colspan="2"><div align="center">修改用户:</div></td>
</tr>
<tr>
<td><div align="center">用户名:</div></td>
<td><input name="uname" type="text" id="uname" value="<%=rs1("uname")%>"></td>
</tr>
<tr>
<td><div align="center">密 码:</div></td>
<td><input name="password" type="text" id="password" value="<%=rs1("password")%>"></td>
</tr>
<tr>
<td><div align="center">权 限:</div></td>
<td>高级管理员:
<input type="radio" name="gl" value="高级管理员">
<input type="hidden" name="ok" value="no"></td>
</tr>
<tr>
<td> </td>
<td>低级管理员:
<input name="gl" type="radio" value="低级管理员" checked>
<input type="hidden" name="id1" value="<%=rs1("id")%>"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="修改">
</div></td>
</tr>
</form>
</table>
<% elseif action<>"删除" then %>
<table width="350" border="1" cellspacing="2" cellpadding="2">
<form name="form1" method="post" action="">
<tr>
<td colspan="2"><div align="center">增加管理用户</div></td>
</tr>
<tr>
<td><div align="center">用户名:</div></td>
<td><input name="uname" type="text" id="uname"></td>
</tr>
<tr>
<td><div align="center">密 码:</div></td>
<td><input name="password" type="text" id="password"></td>
</tr>
<tr>
<td><div align="center">权 限:</div></td>
<td>高级管理员:
<input type="radio" name="gl" value="高级管理员"></td>
</tr>
<tr>
<td> </td>
<td>低级管理员:
<input name="gl" type="radio" value="低级管理员" checked></td>
</tr><input type="hidden" name="ok" value="ok">
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="添加">
</div></td>
</tr>
</form>
</table>
<%
end if
end if %>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?