asp 列出資料並且根據許可權刪除記錄代碼

來源:互聯網
上載者:User

資料庫教程串連程式
set rs=server.CreateObject("adodb.recordset")
set conn=server.CreateObject("adodb.connection")
conn.connectionstring="provider=microsoft.jet.oledb.4.0; data source="&server.mappath("datasource/hhinfo.mdb")

顯示出資料表中的所有資料
<table width="100%" height="25"  border="0" cellpadding="0" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#CCCCCC">
  <tr align="center" bgcolor="#EBEBEB">
    <td height="25">使用者名稱</td>
    <td height="25">使用者類型</td>
    <td height="25">添加時間</td>
 <td height="25">刪除使用者</td>
  </tr>
  <%dim sql
  sql="select * from mange_user"
  call opendb()
  rs.open sql,conn,1,1
  do while not rs.eof
    %>
  <tr align="center" bgcolor="#FFFFFF">
    <td height="25"><%=rs("use_name")%></td>
    <td height="25"><%=rs("use_type")%></td>
    <td height="25"><%=rs("last_login")%></td>
 <td height="25"><a href="deluse.asp?id=<%=rs("id")%>" onclick="javascript教程:return confirm('確實刪除該使用者!')">刪除</a></td>
  </tr>
  <%rs.movenext
  loop
  call closedb()
  %>
</table>

deluse.asp刪除記錄的功能

<% if session("username")="" and session("userpwd")="" and session("use_type")<>"超級管理員" then
response.redirect"login.html"
end if
dim id,sql
id=cint(html_encode(request.QueryString("id")))
if not isnumeric(id) or len(id)=0 then
response.Redirect("login.html")
else
sql="delete * from mange_user where id="&id
sql1="select * from mange_user where id="&id
call opendb()
rs.open sql1,conn,1,1
if not rs.eof then
if rs("use_name")=session("username") or session("use_type")<>"超級管理員" then
response.write("對不起,不能刪除自己或你不是超級管理員<a href=add_use.asp>點擊返回</a>")
response.end()
end if
else
response.Write("刪除失敗<a href=add_use.asp>點擊返回</a>")
end if
conn.execute(sql)
if err=0 then
response.Redirect("add_use.asp")
else
response.Write("刪除失敗<a href=add_use.asp>點擊返回</a>")
end if
end if
call closedb()
%>

本站原創www.111cn.net 轉載註明來源於本站

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.