📄 admin.asp
字号:
<!--#include file="i_login.asp"-->
<%
mode=trim(request("mode"))
id=trim(request("id"))
select case mode
case "add"
call add_sub()
case "save"
call save_sub()
case "del"
call del_sub()
end select
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>后台用户</title>
<LINK href="images/style.css" type=text/css rel=stylesheet>
<script>
function chk(form)
{
if(form.name.value=="" || form.pwd.value=="" ){
alert("未填写完整!");
if(form.name.value==""){
form.name.focus();
}else if(form.pwd.value==""){
form.pwd.focus();
}
return false;
}
else
{
return true;
}
}
</script>
</head>
<body >
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="26" class="gray"> CMS >> 后台用户</td>
</tr>
</table>
<%if mode="edit" then
set rs=conn.execute("select * from data_admin where id="&id&"")
%>
<table border="1" align="center" cellpadding="5" cellspacing="0">
<form name="form1" method="post" action="?" onSubmit="return chk(this);">
<input name="mode" value="save" type="hidden">
<input name="type" value="<%=request("type")%>" type="hidden">
<input name="id" value="<%=id%>" type="hidden">
<tr>
<td align="center" >用户名</td>
<td align="left" ><input name="name" type="text" id="name" size="40" value="<%=rs("name")%>"></td>
</tr>
<tr>
<td align="center" >密 码</td>
<td align="left" ><input name="pwd" type="password" id="pwd" size="45" value="<%=rs("pwd")%>"></td>
</tr>
<tr>
<td colspan="2" align="center" ><input name="Submit" type="submit" id="Submit" value=" 保 存 "></td>
</tr>
</form>
</table>
<%
rs.close
set rs=nothing
else%>
<table border="1" align="center" cellpadding="5" cellspacing="0">
<form name="form2" method="post" action="?" onSubmit="return chk(this);">
<input name="mode" value="add" type="hidden">
<input name="type" value="<%=request("type")%>" type="hidden">
<input name="id" value="<%=id%>" type="hidden">
<tr>
<td align="center" >用户名</td>
<td align="left" ><input name="name" type="text" id="name" size="40"></td>
</tr>
<tr>
<td align="center" >密 码</td>
<td align="left" ><input name="pwd" type="password" id="pwd" size="45"></td>
</tr>
<tr>
<td colspan="2" align="center" ><input type="submit" name="Submit" value=" 添 加 "></td>
</tr>
</form>
</table>
<%end if%>
<hr/>
<table width="50%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#C2BDBD">
<tr>
<td width="69%" height="21" align="center" nowrap bgcolor="#CCCCCC"
>用户名</td>
<td width="31%" align="center" nowrap bgcolor="#CCCCCC"
>操作</td>
</tr><%
set rs=conn.execute("select * from data_admin order by id ")
while not rs.eof
%>
<tr>
<td height="21" align="center" nowrap bgcolor="#FFFFFF"
onmouseover="this.bgColor = '#f0f0f0'" onmouseout="this.bgColor = '#FFFFFF'"><a href="?mode=edit&id=<%=rs("id")%>" class="Af"><%=rs("name")%></a></td>
<td align="center" nowrap bgcolor="#FFFFFF"
onmouseover="this.bgColor = '#f0f0f0'" onmouseout="this.bgColor = '#FFFFFF'"><a href="?mode=edit&id=<%=rs("id")%>" class="Af">编辑</a> <a href="?mode=del&id=<%=rs("id")%>" class="Af"
onclick="javascript:if(confirm('确定删除吗?')){return true;}else{return false;}">删除</a></td>
</tr>
<%
rs.movenext
wend
rs.close
set rs=nothing
%>
</table>
</body>
</html>
<%
conn.close
set conn=nothing
%>
<%
sub add_sub()
name=trim(request.Form("name"))
pwd=trim(request.Form("pwd"))
if name="" or pwd="" then
call msg("未填写完整!","-1")
end if
conn.execute("insert into data_admin(name,pwd) values('"&name&"','"&md5(pwd,32)&"')")
end sub
sub save_sub()
name=trim(request.Form("name"))
pwd=trim(request.Form("pwd"))
dj=trim(request.Form("dj"))
if name="" or pwd="" then
call msg("未填写完整!","-1")
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from data_admin where id="&id&"",conn,1,2
rs("name")=name
if rs("pwd")<>pwd then
rs("pwd")=md5(pwd,32)
end if
rs.update
rs.close
set rs=nothing
end sub
sub del_sub()
conn.execute("delete from data_admin where id="&id&"")
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -