| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 486 人关注过本帖
标题:[求助]像这样怎么实现
只看楼主 加入收藏
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
结帖率:68.57%
收藏
 问题点数:0 回复次数:8 
[求助]像这样怎么实现
各位老师:
我想当点击“删除”时,希望系统会判断——如是管理员,就给予删除(当进入系统的用户名为“张三”,就是管理员,也就是说只有张三才有删除的权限),不是管理员的,也就是说进入系统时的用户名不是“张三”的,当他点击“删除”时,系统会提示:“对不起!您不是管理员,您没有权限删除!”
下面是我的代码,但是这样的设计,进去的每个人都有删除的权限,请问!实现上面的功能,怎么实现!谢谢!

————————————————————————————————————————————
// 下面是feijichangfahuo.asp页面中有关删除的代码

<%
'--------------------------删除单条记录
if request("method")="del" then
id=request("id")
sql = "DELETE FROM fjcfh WHERE id=" + cstr(id)
conn.execute sql
response.Write "<script >"
response.Write("alert('删除操作成功!');")
response.Write("window.navigate('feijichangfahuo.asp')")
response.Write("</script>")
%>
<%
end if
%>

————————————————————————————————————————————
<%
response.Write("<a href='javascript:SureDelSingle(" & cstr(rs("id")) & ")'>删除</a>")
%>
// 当点击上面红色的“删除”时,想实现我说的功能!
————————————————————————————————————————————
<script language="JavaScript" >

function SureDelSingle(id)
{
if ( confirm("您确定要删除本条信息吗?"))
{
window.location.href = "feijichangfahuo.asp?method=del&id=" +id;
}
}
</script>
————————————————————————————————————————————

[此贴子已经被作者于2006-3-6 15:49:49编辑过]

搜索更多相关主题的帖子: 用户名 管理员 
2006-03-06 14:03
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 
老师们帮帮我。谢谢!!

[此贴子已经被作者于2006-3-6 15:56:10编辑过]



我是农家的孩子,我有农家孩子的本色!
2006-03-06 14:07
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 

[CODE]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>:::飞机场发货录入窗口:::</title>
<link href="../css/fontsize.css" rel="stylesheet" type="text/css">
<link href="../css/input_form.css" rel="stylesheet" type="text/css">
<link href="../css/inputform1.css" rel="stylesheet" type="text/css">
<link href="../css/selectform.css" rel="stylesheet" type="text/css">
<link href="../css/inputform2.css" rel="stylesheet" type="text/css">
<link href="../css/inputform3.css" rel="stylesheet" type="text/css">
<link href="../css/inputform3.css" rel="stylesheet" type="text/css">
<link href="../css/link.css" rel="stylesheet" type="text/css">
<link href="../css/buttoncss.css" rel="stylesheet" type="text/css">
<link href="../css/inputchaxun.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-image: url(../pictures/0343.jpg);
}
.style6 {color: #666666}
.style7 {color: #006666}
.style8 {color: #999999}
.style9 {color: #FF0000}
.style10 {color: #000000}
.style12 {color: #339999}
.style13 { color: #336699;
font-size: 12px;
}
.style15 {font-size: 12px}
.style16 {color: #339999; font-size: 12px; }
.style3 {color: #336699}
.style4 {color: #0000FF}
-->
</style>
</head>
<body bgcolor="#6699cc" onload="setup()" >
<p>
<%
'--------------------------删除单条记录
if request("method")="del" then
id=request("id")
sql = "DELETE FROM fjcfh WHERE id=" + cstr(id)
conn.execute sql
response.Write "<script >"
response.Write("alert('删除操作成功!');")
response.Write("window.navigate('feijichangfahuo.asp')")
response.Write("</script>")
%>
<%
end if
%>
</p>
<p align="center"><font color="#660000" size="2"><img src="../pictures/fox.gif" width="35" height="31">&nbsp;&nbsp;</font> <span class="style12"><span class="style13">◆</span></span><span class="style13">飞机场发货录入窗口
2006-3-3版 ◆</span><span class="style16"></span></p>
<tr>
<td width="100%" height="65" background="../pictures/0343.jpg"> <table width="800" height="27" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#666666" class="fontsize" style="border-collapse: collapse">
<form name="chaxun_form" action="feijichangfahuo.asp" method="post" >
<tr align="center" valign="middle" background="../pictures/01menu_bg.gif" >
<td width="16%" height="22" background="../pictures/01menu_bg.gif"> <div align="center">操作员</div></td>
<td width="35%" height="22" background="../pictures/01menu_bg.gif"><div align="center">
<input name="qjy" type="text" class="inputform1" id="qjy">
</div></td>
<td width="14%" height="22" background="../pictures/01menu_bg.gif"><div align="center">运单号</div></td>
<td width="23%" height="22" background="../pictures/01menu_bg.gif"> <div align="center">
<input name="hbh" type="text" class="inputform1" id="hbh">
</div></td>
<td width="12%" height="22" > <div align="center">
<input name="chaxun" type="submit" id="chaxun2" value="我要查询">
</div></td>
</tr>
</form>
</table>
<form name="input_form" action="add_feijichangfahuo.asp" method="post" onSubmit="return checkform();">
<table width="800" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#666666" style="border-collapse: collapse">
<tr>
<td height="23" colspan="5" background="../pictures/01menu_bg.gif"><div align="left"><font size="2">&nbsp;
&nbsp;&nbsp;◆
以下为添加信息部分:</font></div></td>
<td width="247" height="23" background="../pictures/01menu_bg.gif"><div align="right"><font size="2"><span class="style10">&nbsp;信息录入:</span><span class="style7">&nbsp; 【<span class="style4"><%=session("name")%></span>】 </span></font></div></td>
</tr>
<tr>
<td width="100" background="../pictures/01menu_bg.gif"><table width="100" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="100" height="15"><div align="right"><font size="2">发货日期:&nbsp;&nbsp;&nbsp;</font></div></td>
</tr>
</table></td>
<td colspan="3"><font size="2">
<input name="rq" type="text" class="inputform1" id="num_of_riqi3" onMouseOver="this.focus();" value="<%=date()-1%>" size="15">
</font></td>
<td width="103" background="../pictures/01menu_bg.gif"><div align="right">
<table width="100" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="100" height="15"><div align="right"><font size="2"> 票&nbsp;&nbsp;数:&nbsp;&nbsp;&nbsp;</font></div></td>
</tr>
</table>
</div></td>
<td><div align="left"> <font size="2">
<input name="ps" type="text" class="inputform1" id="num_of_students3" onMouseOver="this.focus();" size="10">
</font><span class="style6"> <font size="2">票<span class="style4">(有几张总运单就为几票) </span></font></span> </div></td>
</tr>
<tr >
<td background="../pictures/01menu_bg.gif"><table width="100" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="100" height="15"><div align="right"><font size="2">件&nbsp;&nbsp;数:&nbsp;&nbsp;&nbsp;</font></div></td>
</tr>
</table></td>
<td colspan="3"><font size="2">
<input name="js" type="text" class="inputform1" id="num_of_riqi3" onMouseOver="this.focus();" size="15">
</font><span class="style6"><font size="2">件(总运单上的件数) </font></span></td>
<td background="../pictures/01menu_bg.gif"><div align="right">
<table width="100" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="100" height="15"><div align="right"><font size="2"> 重&nbsp;&nbsp;量:&nbsp;&nbsp;&nbsp;</font></div></td>
</tr>
</table>
</div></td>
<td><div align="left"> <font size="2">
<input name="zl" type="text" class="inputform1" id="num_of_students3" onMouseOver="this.focus();" size="10">
</font><span class="style6"><font size="2">KG(总运单上的重量) </font></span> </div></td>
</tr>
<tr >
<td background="../pictures/01menu_bg.gif"><div align="right">
<table width="100" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="100" height="15"><div align="right"><font size="2"> 运单号:&nbsp;&nbsp;&nbsp;</font></div></td>
</tr>
</table>
</div></td>
<td colspan="3"><div align="left"> <font size="2">
<input name="hbh" type="text" class="inputform1" id="num_of_fjd3" onMouseOver="this.focus();" size="15">
</font> </div></td>
<td background="../pictures/01menu_bg.gif"><table width="100" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="100" height="15"><div align="right"><font size="2">操作员:&nbsp;&nbsp;&nbsp;</font></div></td>
</tr>
</table></td>
<td><font size="2">
<select name="qjy" id="qjy">
<option>-操作员-</option>
<option value="张三">Z 张三</option>
<option value="王二">W 王二</option>
<option value="麻子">M 麻子</option>

</select>
</font></td>
</tr>
<tr >
<td height="43" colspan="6"> <div align="center">
<input type=submit value=完成录入 name=Submit>
&nbsp;
<input type=reset value=清空重写 name=Submit_a>
</div></td>
</tr>
</table>
</form>
<p><span class="style8"><font size="2"><span class="style6"> <font size="2"><span class="style3"><font color="#660000" size="2">&nbsp;&nbsp;<span class="style15"><span class="style7 style15">&nbsp;&nbsp;&nbsp;</span></span></font><font size="2"><span class="style15"></span><span class="style10">◆</span>下表是【<span class="style4"><font size="2"><%=date()-1%></font></span>】飞机场发货记录表单:</font></span></font></span></font></span></p></td>
</tr><tr> </tr>
<tr>

<td background="../pictures/0343.jpg">
<table width="800" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#666666" style="border-collapse: collapse">
<tr align="center" valign="middle" class="fontsize">
<td height="22" nowrap background="../pictures/01menu_bg.gif"><div align="center">操作员</div></td>
<td nowrap background="../pictures/01menu_bg.gif"><div align="center">发货地点</div></td>
<td nowrap background="../pictures/01menu_bg.gif"><div align="center">运单号</div></td>
<td height="22" nowrap background="../pictures/01menu_bg.gif"> <div align="center">发货日期</div></td>
<td height="22" nowrap background="../pictures/01menu_bg.gif"> <div align="center">重量</div></td>
<td height="22" nowrap background="../pictures/01menu_bg.gif"> <div align="center">票数</div></td>
<td height="22" nowrap background="../pictures/01menu_bg.gif"><div align="center">件数</div></td>
<td height="22" colspan="2" nowrap background="../pictures/01menu_bg.gif"> <div align="center">操作</div></td>
</tr>
<%
set rs=server.CreateObject("adodb.recordset")
if request("chaxun")="我要查询" then
sql= "select * from fjcfh where qjy like '%"&trim(request("qjy"))&"%' and hbh like '%"&trim(request("hbh"))&"%' order by id desc"
else
sql="select * from fjcfh where rq like #"&date()-1&"# order by id desc"
end if
rs.open sql,conn,1,1
if rs.recordcount <> 0 then
rs.movefirst
do while not rs.eof
%>
<tr align="center" valign="middle" class="fontsize">
<td nowrap background="../pictures/01menu_bg.gif"><div align="center">&nbsp;<%=rs("qjy")%>&nbsp;</div></td>
<td nowrap><div align="center">&nbsp;<%=rs("shdd")%>&nbsp;</div></td>
<td nowrap><div align="center">&nbsp;<%=rs("hbh")%>&nbsp;</div></td>
<td height="22" nowrap> <div align="center">&nbsp;<%=rs("rq")%>&nbsp;</div></td>
<td height="22" nowrap> <div align="center">&nbsp;<%=rs("zl")%>&nbsp;</div></td>
<td height="22" nowrap> <div align="center">&nbsp;<%=rs("ps")%>&nbsp;</div></td>
<td height="22" nowrap><div align="center">&nbsp;<%=rs("js")%>&nbsp;</div></td>
<td width="33" height="22" nowrap background="../pictures/01menu_bg.gif"> <div align="center">
<%
response.Write("<a href='javascript:SureDelSingle(" & cstr(rs("id")) & ")'>删除</a>")
%>
</div></td>
<td width="33" height="22" nowrap background="../pictures/01menu_bg.gif"> <div align="center"><a href="modify_feijichangfahuo.asp?id=<%=rs("id")%>">修改</a>
</div></td>
</tr>
<%
rs.movenext
loop
else
%>
<tr class="fontsize">
<td height="22" colspan="7" ><div align="center" class="style9"><font size="2">对不起,没有此信息!</font></div></td>
</tr>
<%

end if
%>
</table>
</td>
</tr>
<p><%
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
</p>
</body>
<script language="JavaScript" >
var xingbie = "男";
function checkform()
{
var subst = document.input_form;
if (subst.rq.value=="")
{
alert("对不起!发货日期不能为空!");
subst.rq.focus();
return false;
}
if (subst.ps.value=="")
{
alert("对不起!票数不能为空哦!");
subst.ps.focus();
return false;
}
if (subst.ps.value!="")
{
if(onlyNum(subst.ps.value)==0)
{
alert("对不起!票数只能输入数字!");
subst.ps.focus();
return false;
}
}
if (subst.js.value=="")
{
alert("对不起!件数不能为空哦!");
subst.js.focus();
return false;
}
if (subst.js.value!="")
{
if(onlyNum(subst.js.value)==0)
{
alert("对不起!件数只能输入数字!");
subst.js.focus();
return false;
}
}
if (subst.zl.value=="")
{
alert("对不起!重量不能为空哦!");
subst.zl.focus();
return false;
}
if (subst.zl.value!="")
{
if(onlyNum(subst.zl.value)==0)
{
alert("对不起!重量只能输入数字!");
subst.zl.focus();
return false;
}
}
if (subst.hbh.value=="")
{
alert("对不起!运单号不能为空哦!");
subst.hbh.focus();
return false;
}
if (subst.hbh.value!="")
{
if(onlyNum(subst.hbh.value)==0)
{
alert("对不起!运单号只能输入数字!");
subst.hbh.focus();
return false;
}
}
if (subst.qjy.value=="")
{
alert("对不起!操作员姓名一定要写!因为会涉及到其工作量!");
subst.qjy.focus();
return false;
}
return true;
}
function Caculate_PointNum(this_value)
{
var i,j=0;
for (i=0;i<this_value.length;i++)
{
if (this_value.charAt(i)==".")
{
j++;
}
}
return j;
}
function onlyNum(NUM)
{
var i,j,strTemp;
strTemp="0123456789.-";
if ( NUM.length== 0)
return 0
for (i=0;i<NUM.length;i++)
{
j=strTemp.indexOf(NUM.charAt(i));
if (j==-1)
{
//说明有字符不是数字
return 0;
}
}
//说明是数字
return 1;
}
function onlyNum_Point(NUM)
{
var i,j,strTemp;
strTemp="0123456789.";
if ( NUM.length== 0)
return 0
for (i=0;i<NUM.length;i++)
{
j=strTemp.indexOf(NUM.charAt(i));
if (j==-1)
{
//说明有字符不是数字
return 0;
}
}
//说明是数字
return 1;
}
function SureDelSingle(id)
{
if ( confirm("您确定要删除本条信息吗?"))
{
window.location.href = "feijichangfahuo.asp?method=del&id=" +id;
}
}
</script>
</html>[/CODE]


我是农家的孩子,我有农家孩子的本色!
2006-03-06 15:59
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 

有老师在吗?


我是农家的孩子,我有农家孩子的本色!
2006-03-06 18:42
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 
在线等

我是农家的孩子,我有农家孩子的本色!
2006-03-06 19:38
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
用Session呀,登陆时把用户名存储到Session中。判断权限时读取Session用户名判断
比如如下函数
function verifyLeg(UserName)
Dim rsVL
Set rsVL=con.Execute("select * From 管理员表 Where 管理员='"&UserName&"'")
IF rsVL.EOF Then
verifyLeg="F"
Else
verifyLeg="T"
End IF
rsVL.Close
Set rsVL=Nothing
End Function
判断时
IF verifyLeg(Session("UserName"))="F" Then
Response.Write "alert('对不起,您不是管理员,不能执行此操作');"
End IF
2006-03-06 22:15
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 
是呀!我也想用<%=session("name")%>来判断,但是如我用<%=session("name")%>,在上面我写的删除代码里该怎么改?谢谢!!

我用户表名为USER
姓名字段是:NAME

我是农家的孩子,我有农家孩子的本色!
2006-03-07 13:50
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
function verifyLeg(UserName)
Dim rsVL
Set rsVL=con.Execute("select * From [user] Where NAME='"&UserName&"'")
IF rsVL.EOF Then
verifyLeg="F"
Else
verifyLeg="T"
End IF
rsVL.Close
Set rsVL=Nothing
End Function
if request("method")="del" then
'这里加判断权限代码
IF verifyLeg(Session("UserName"))="F" Then
response.Write "<script >"
response.Write("alert('对不起,您的用户信息不存在,不能执行此操作');")
response.Write("window.navigate('feijichangfahuo.asp')")
response.Write("</script>")
Else
id=request("id")
sql = "DELETE FROM fjcfh WHERE id=" + cstr(id)
conn.execute sql
response.Write "<script >"
response.Write("alert('删除操作成功!');")
response.Write("window.navigate('feijichangfahuo.asp')")
response.Write("</script>")
End IF
放到执行删除操作的代码前,进行验证。
2006-03-07 17:31
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 
谢谢!我试一下!

我是农家的孩子,我有农家孩子的本色!
2006-03-08 12:03
快速回复:[求助]像这样怎么实现
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018991 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved