asp 循环判断语句 (急)满意追加 50分

来源:百度知道 编辑:UC知道 时间:2024/05/28 08:26:49
<%
if tj="普通会员" then
if session("username")="" then
response.Write("<script>alert('对不起!请先登录!');window.location.replace('"&request.ServerVariables("HTTP_REFERER")&"');</script>")
response.end()
if tj="高级会员" then
if session("sh")="未审核" then
response.write "<script>"
response.write "alert ('您的信息尚未通过审核请稍候再试!');"
response.write "window.location.replace('"&request.ServerVariables("HTTP_REFERER")&"');"
response.write "</script>"
response.end()
end if
end if
end if
end if
%>

要实现的功能:

如果tj="普通会员" 那么判断 session("username")="需要登陆"
如果tj="高级会员" 那么判断 session("sh")="已经审核"

希望高手做详细的说明,偶是菜鸟,不要笑偶.

另外要实现,用户历次累计登陆时

假如会员表为User,用户名字段为Username
在User表添加个Userip(文本)/Lasttime(时间)/Onlinetime(数字)字段
然后在全部的页面里加上下面代码即可实现,你也可以放到类似top.asp文件里面,只要用户在任何页面都能执行到下面代码就可以了。
<%
'rs("onlinetime")是在线时间,单位:分钟。
vcounti=600'累加访问数间隔时间(秒),一般设置成600秒左右;
if session("username")>"" then
if DateDiff("s",CDate(Application("ltime_"&session("username"))),Now)>vcounti then'间隔{vcounti}秒才去操作数据库记录
Application("ltime_"&session("username"))=Now'储存最后一次访问的时间
sql="select top 1 * from [user] where username='"&session("username")&"'"
rs.open(sql),conn,1,2'打开该用户表
rs("lasttime")=Now()
rs("UserIP")=UserIP()
rs("onlinetime")=rs("onlinetime")+vcounti/60