ASP lists data and deletes record code based on permissions

Source: Internet
Author: User

Database Tutorial Connection Program
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 ")

Display all the data in a datasheet
<table width= "100%" height= "border=" 0 "cellpadding=" 0 "cellspacing=" 1 "bordercolor=" #CCCCCC "bgcolor=" #CCCCCC " >
&LT;TR align= "center" bgcolor= "#EBEBEB" >
&LT;TD height= > Username </td>
&LT;TD height= > User Type </td>
&LT;TD height= > Add Time </td>
&LT;TD height= > Delete user </td>
</tr>
<%dim SQL
Sql= "SELECT * from Mange_user"
Call OPENDB ()
Rs.Open sql,conn,1,1
Do as not rs.eof
%>
&LT;TR align= "center" bgcolor= "#FFFFFF" >
&LT;TD height= "><%=rs" ("Use_name")%></td>
&LT;TD height= "><%=rs" ("Use_type")%></td>
&LT;TD height= "><%=rs" ("Last_login")%></td>
&LT;TD height= "><a href=" deluse.asp?id=<%=rs ("id")%> "onclick=" JavaScript Tutorial: Return confirm (' Do delete this user !')" > Delete </a></td>
</tr>
<%rs.movenext
Loop
Call Closedb ()
%>
</table>

Deluse.asp the ability to delete records

<% if session ("username") = "" "and Session (" userpwd ") =" "and Session (" Use_type ") <>" Super Administrator "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 whe Re 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 ") <>" Super admin "then
Response.Write (" Sorry, can't remove yourself or you are not Super Admin <a href=add_use.asp> Click Back </a> ")
Response.End ()
End If
Else
response. Write (Delete failed <a href=add_use.asp> click Back </a>)
End If
conn.execute (SQL)
If err=0 then
Response. Redirect ("add_use.asp")
Else
Response. Write (Delete failed <a href=add_use.asp> click Back </a>)
End If
End If
call Closedb ()
%>

Site original www.111cn.net reproduced annotated from this site

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.