我把代码贴出来吧! 这个是弹出页面admin.asp: <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="connections/conn.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>--設置--</title>
<%' 新增用戶 username=request("username") pwd=request("pwd") right_id=request("right_id") realname=request("realname") work_group=request("group") set us= Server.CreateObject("adodb.recordset") use="select username from tbl_user where username='"&username&"'" us.open use,mm_conn_string,1,1
if request("Submit")="提交"then if request("username")="" then %> <script language="javascript"> alert("用戶名不能為空!"); </script> <% elseif not us.eof then %> <script language="javascript"> alert("此用戶名已存在!"); </script>
<% elseif request("pwd")="" then
%> <script language="javascript"> alert("密碼不能為空!"); </script> <% elseif request("realname")="" then %> <script language="javascript"> alert("請輸入姓名!"); </script> <% else set rs=Server.CreateObject("adodb.recordset") sql="insert into tbl_user(username,name,work_group,pwd,right_id)values('"&cstr(request("username"))&"','"&cstr(request("realname"))&"','"&work_group&"','"&cstr(request("pwd"))&"','"&cstr(request("right_id"))&"')" 'response.write sql rs.open sql,mm_conn_string,1,1
%> <script language="javascript"> <!-- alert("用戶添加成功!"); window.close(); </script> <% end if end if %>
<style type="text/css"> <!-- a:link { text-decoration: none; } a:visited { text-decoration: none; } a:hover { text-decoration: none; } a:active { text-decoration: none; } .style2 {font-size: 12px} input { font-size: 9pt; background-color: #CCCCCC; } select { font-size: 9pt; background-color: #CCCCCC; } --> </style> <body bgcolor="#D9E1FB"> <!--#include file="win.asp"--> <% if session("username")="" then %> <script language="javascript"> alert("網頁過期啦!請重新登陸!呵呵!"); window.close(); </script> <%end if%> <p> <% if request("action")="aduser"then %> </p> <form action="admin.asp?action=aduser" method="post" name="form1" class="style2"> <div align="center">新增用戶</div> <table width="162" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999"> <tr bgcolor="#D9E1FB"> <td width="45" height="24" align="center" bgcolor="#D9E1FB">用戶名</td> <td width="114"><input name="username" type="text" id="username" value="<%=request("username")%>" size="10" style="font-size:12px "></td> </tr> <tr bgcolor="#D9E1FB"> <td height="22" align="center" bgcolor="#D9E1FB">密 碼</td> <td><input name="pwd" type="text" id="pwd" value="<%=pwd%>" size="10"></td> </tr> <tr bgcolor="#D9E1FB"> <td height="25" align="center" bgcolor="#D9E1FB">姓 名</td> <td><input name="realname" type="text" id="realname" value="<%=realname%>" size="10"></td> </tr> <tr bgcolor="#D9E1FB"> <td height="25" align="center" bgcolor="#D9E1FB">組 別</td> <td> <%if session("rght_id")<>3then%> <input type="hidden" name="group" id="group" <%if session("right_id")=3then%>disabled<%end if%> value="<%=session("work_group")%>"> <%end if%> <select name="group" id="group"<%if session("right_id")<>3then%> disabled<%end if%>> <option><%=session("work_group")%></option> <option value="系統開發組">系統開發組</option> <option value="網絡維護組">網絡維護組</option> <option value="教育訓練組">教育訓練組</option> <option value="系統管理組">系統管理組</option> </select> </td> </tr> <tr bgcolor="#D9E1FB"> <td align="center" bgcolor="#D9E1FB">屬 性</td> <td> <select name="right_id" id="right_id"> <option value="1">普通用户</option> <option value="2">高级用户</option> <%if session("right_id")=3then%> <option value="3">管理員</option> <%end if%> </select> </td> </tr> <tr bgcolor="#D9E1FB"> <td> </td> <td class="style2"> <input type="submit" name="Submit" value="提交"> <input type="button" name="Submit" value="取消" onClick="window.close();"> </td> </tr> </table> </form> <p> <% end if if request("action")="up"then%> <%'修改密碼 if request("Submit")="修改"then if request("pwd")="" or request("rpwd")=""then %> <script language="javascript"> alert("密碼不能為空!"); </script> <% elseif request("pwd")<>request("rpwd") then %> <script language="javascript"> alert("您兩次輸的密碼不一緻!"); </script> <% elseif session("username")=""then %> <script language="javascript"> alert("網頁已過期,請從新登陸!") window.close(); </script> <% response.redirect "login.asp" else set rs= Server.CreateObject("adodb.recordset") sql="update tbl_user set pwd='"&request("pwd")&"'where username='"&session("username")&"'" 'response.Write sql rs.open sql,mm_conn_string,1,1 %> <script language="javascript"> alert("密碼修改成功!"); window.close(); </script> <% end if end if %> </p> <p> </p> <form action="admin.asp?action=up" method="post" name="form2" class="style2"> <div align="center">修改密碼 </div> <table width="162" height="69" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999"> <tr bgcolor="#D9E1FB"> <td width="40" height="22" align="center">新密碼</td> <td width="119"><input name="pwd" type="password" id="pwd" size="10" maxlength="10"></td> </tr> <tr bgcolor="#D9E1FB"> <td height="21" align="center">確 認</td> <td><input name="rpwd" type="password" id="rpwd" size="10"></td> </tr> <tr bgcolor="#D9E1FB"> <td height="22"> </td> <td> <input type="submit" name="Submit" value="修改"> <input type="button" name="Submit" value="取消" onClick="window.close();"> </td> </tr> </table> </form> <p> <% End If %> <%if request("action")=""then%> </p> <p> </p> <table width="200" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center" valign="middle"><p align="center" class="style2"><a href="admin.asp?action=<%="aduser"%>&"> <%if session("right_id")=2 or session("right_id")=3then%> 添加用戶 <%end if%> </a></p> <p align="center"><span class="style2"><a href="admin.asp?action=<%="up"%>"> <% if session("right_id")=1 or session("right_id")=2 or session("right_id")=3then %> 修改密碼 <% end if %> </a></span></p> <p align="center" class="style2"><a href="admin.asp?action=<%="user"%>"> <%if session("right_id")=2 or session("right_id")=3then%> 用戶管理 <%end if%> </a></p> <p align="center"> </p></td> </tr> </table><%end if%> <%
if request("action")="user"then set rs1= Server.CreateObject("adodb.recordset") if session("right_id")=3then sql1="select * from tbl_user " else sql1="select * from tbl_user where work_group='"&session("group")&"'" end if rs1.open sql1,mm_conn_string,1,1 rs1.pagesize=5 pagecount1=rs1.pagecount if request("pagenum")=0 or request.QueryString("pagenum")="" then pagenum=1 else pagenum=request.QueryString("pagenum") rs1.absolutepage=trim(request.QueryString("pagenum")) end if %> <table width="193" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000"> <tr align="center" bgcolor="#818ACF"> <td width="37"><span class="style2">用戶名</span></td> <td width="37"><span class="style2">姓名</span></td> <td width="31"><span class="style2">組別</span></td> <td width="32"><span class="style2">權限</span></td> <td width="50" class="style2"><span class="style2">编</span>辑</td> </tr> <% i=0 do while not rs1.eof and i<rs1.pagesize%><tr align="center" bgcolor="#D9E1FB"> <td><span class="style2"><%=rs1("username")%></span></td> <td><span class="style2"><%=rs1("name")%></span></td> <td><span class="style2"><%=rs1("work_group")%></span></td> <td><span class="style2"><%if cstr(rs1("right_id"))=1 then response.write("普通用戶") elseif cstr(rs1("right_id"))=2 then response.write("高級用戶") else response.write("管理員") end if%></span></td> <td><span class="style2">[<a href="admin.asp?action=upus&username=<%=rs1("username")%>&realname=<%=rs1("name")%>&pwd=<%=rs1("pwd")%>&right_id=<%=rs1("right_id")%>&work_group=<%=rs1("work_group")%>">修改</a>][<a href="admin.asp?action=del&username=<%=rs1("username")%>" onClick="return confirm('確定要刪除 <%=rs1("username")%> 這個用戶?');">删除</a>]</span></td> </tr><%i=i+1 rs1.movenext loop %> </table> <center class="style2"> <%if rs1.pagesize<rs1.recordcount then%> <%if cint(pagenum)<>1 then%> <a href="admin.asp?action=user&pagenum=1">首頁</a> <%'end if%> <%'if pagenum>1 then%> <a href="admin.asp?action=user&pagenum=<%=(pagenum-1)%>">上一頁</a> <%end if%> <%if cint(pagenum)<>cint(pagecount1) then%> <a href="admin.asp?action=user&pagenum=<%=(pagenum+1)%>">下一頁</a> <%'end if%> <%'if pagecount1<(pagenum) then%> <a href="admin.asp?action=user&pagenum=<%=pagecount1%>">尾頁</a> <%end if%> <%end if end if%> </center> <p> <%if request("action")="del" then 'response.Write request("username") set rs= Server.CreateObject("adodb.recordset") sql="delete from tbl_user where username='"+cstr(request("username"))+"'" rs.open sql,mm_conn_string,1,1 'response.Write sql response.Redirect "admin.asp?action=user" %> <% end if %> </p> <p> <%if request("action")="upus"then%> <% if request("Subm")="修改"then if request("realname1")="" then %> <script language="javascript"> alert("請輸入姓名!"); </script> <% elseif request("pwd1")="" then
%> <script language="javascript"> alert("密碼不能為空!"); </script> <% else if request("group1")=""then group1=session("group") else group1=request("group1") end if set rs=Server.CreateObject("adodb.recordset") sql="update tbl_user set name='"&request("realname1")&"',pwd='"&request("pwd1")&"',work_group='"&group1&"',right_id='"&request("right_id1")&"'where username='"&request("username")&"' " 'response.write sql rs.open sql,mm_conn_string,1,1 response.Redirect "admin.asp?action=user" end if end if %> </p> <form name="form3" action="" method="post"> <table width="162" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999"> <tr bgcolor="#D9E1FB"> <td width="49" height="24" align="center" bgcolor="#D9E1FB"><span class="style2">用戶名</span></td> <td width="110"><%=username%></td> </tr> <tr bgcolor="#D9E1FB"> <td height="22" align="center" bgcolor="#D9E1FB"><span class="style2">密 碼</span></td> <td><input name="pwd1" type="password" id="pwd1" value="<%=pwd%>" size="10"></td> </tr> <tr bgcolor="#D9E1FB"> <td height="24" align="center" bgcolor="#D9E1FB"><span class="style2">姓 名</span></td> <td><input name="realname1" type="text" id="realname1" value="<%=realname%>" size="10"></td> </tr> <%if session("right_id")=3then%><tr bgcolor="#D9E1FB"> <td height="25" align="center" bgcolor="#D9E1FB"><span class="style2">組 別</span></td> <td><select name="group1" id="group1" > <option value="<%=request("work_group")%>"><%=request("work_group")%></option> <option value="系統開發組">系統開發組</option> <option value="網絡維護組">網絡維護組</option> <option value="教育訓練組">教育訓練組</option> <option value="系統管理組">系統管理組</option> </select> </td> </tr><%end if%> <tr bgcolor="#D9E1FB"> <td height="25" align="center" bgcolor="#D9E1FB"><span class="style2">屬 性</span></td> <td><select name="right_id1" id="right_id1"> <option value="<%=request("right_id")%>"><%if request("right_id")=1 then%>普通用户<%elseif request("right_id")=2 then%>高级用户<%else%>管理員<%end if%></option> <option value="1">普通用户</option> <option value="2">高级用户</option> <%if session("right_id")=3then%> <option value="3">管理員</option> <%end if%> </select> </td> </tr> <tr bgcolor="#D9E1FB"> <td><span class="style2"></span></td> <td class="style2"><input name="Subm" type="submit" id="Subm" value="修改"> <input name="Submit" type="submit" value="取消"> </td> </tr> </table> </form> <%if request("Submit")="取消"then response.Write request("Submit") response.Redirect "admin.asp?action=user" end if %> <%end if%> <p> </p> </body> </html> 下面是弹出函数win.asp: <SCRIPT LANGUAGE="javascript"> <!-- function openwin() { window.open ('admin.asp', 'newwindow', 'height=200, width=250, top=200,left=250, toolbar=0, menubar=no, scrollbars=no, resizable=no,location=no, status=no') }//写成一行 --> </SCRIPT>
[此贴子已经被作者于2005-3-12 16:30:24编辑过]