永发信息网

求助:asp登陆写入时间和加积分

答案:2  悬赏:50  手机版
解决时间 2021-06-02 14:35
  • 提问者网友:酱爆肉
  • 2021-06-01 13:42

我是菜鸟,想给网站的会员每天第一次登陆的时候加2分积分,同时把会员最后一次登陆的时间写入access数据库里,不知道该怎样实现,下面是会员登陆验证的代码,希望高手们帮个忙!小弟感激不尽!

<%
If request("act")="login" Then
username = request.Form("username")
password = md5(Request("password"))
code = request.Form("code")
If username = "" Then
response.Write("<script language=javascript>alert('用户名不能为空!');window.location.href='users_login.asp'</script>")
response.End
End If
If password = "" Then
response.Write("<script language=javascript>alert('密码不能为空!');window.location.href='users_login.asp'</script>")
response.End
End If
If code = "" Then
response.Write("<script language=javascript>alert('验证码不能为空!');window.location.href='users_login.asp'</script>")
response.End
End If
If code<>Session("getcode") then
response.Write("<script language=javascript>alert('验证码错误!');window.location.href='users_login.asp'</script>")
response.End
End If
sql = "select * from users where username='"&username&"' and password='"&password&"'"
Set rs = conn.Execute(sql)
If rs.EOF Or rs.bof Then
response.Write "<script language=javascript>"
response.Write "alert('帐号或者密码错误,请重新输入!');"
response.Write "javascript:window.location.href='users_login.asp';"
response.Write "</script>"
Else
session("username") = username
session.Timeout = 600
response.redirect "users.asp"
End If
End if
%>

最佳答案
  • 五星知识达人网友:风格不统一
  • 2021-06-01 14:05


sql = "select * from users where username='"&username&"' and password='"&password&"'"
Set rs = conn.Execute(sql)
If rs.EOF Or rs.bof Then
response.Write "<script language=javascript>"
response.Write "alert('帐号或者密码错误,请重新输入!');"
response.Write "javascript:window.location.href='users_login.asp';"
response.Write "</script>"
Else
session("username") = username
session.Timeout = 600
response.redirect "users.asp"
End If
End if



改成



sql = "select * from users where username='"&username&"' and password='"&password&"'"
Set rs = conn.Execute(sql)
If rs.EOF Or rs.bof Then
response.Write "<script language=javascript>"
response.Write "alert('帐号或者密码错误,请重新输入!');"
response.Write "javascript:window.location.href='users_login.asp';"
response.Write "</script>"
Else
session("username") = username
if formatdatetime(rs("time"),2)=date() then
conn.execute("update users set 积分字段=积分字段+2,time='"&now()&"' where username='"&username&"'"
else
conn.execute("update users set time='"&now()&"' where username='"&username&"'"
end if
session.Timeout = 600
response.redirect "users.asp"
End If
End if



我把你的时间字段假设为 time


全部回答
  • 1楼网友:夜风逐马
  • 2021-06-01 15:08

在这个位置 session("username") = username

增加:

增加积分语句 conn.execute("update users set 积分字段=积分字段+2,最后日期=now where username='"&username&"' and datediff('d',now,最后日期)<>0)"

conn.execute("update users set 最后日期=now where username='"&username&"')"

只是思路,没有测试

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯