日期:2014-05-17 浏览次数:21016 次
<%
'date signtime = formatdatetime(now,2)
'response.Write(signtime)
'Year(now())
'Month(now())
'day(now())
set conn=server.CreateObject("adodb.connection")
DBPath = Server.MapPath("/signin/20120720.mdb")
conn.open "provider=microsoft.jet.oledb.4.0; data source="&DBpath
set rs=conn.execute ("select time as st from sign where username = '"&username&"'")
str =""
if rs.eof then
set rs=conn.execute ("insert into sign (username) Values ('"&username&"')")
If DateDiff("h",CDate(st),st) > 24 then '这里我还不知道怎么比较
%>
<script language="JavaScript">
alert("今日已经签到!")
history.go(-1)
</script>
<%
else
sql = "update sign set times = times + 1 and time = '"&Year(now())-Month(now())-day(now())&"' where username = "&username&"'"
conn.execute (sql)
%>
<script language="JavaScript">
alert("签到成功!")
history.go(datecheck.asp)
</script>
<%
end if
end if
%>
<%
username = "xxxx"
Set conn = CreateObject("adodb.connection")
DBPath = Server.MapPath("/signin/20120720.mdb")
conn.open "provider=microsoft.jet.oledb.4.0; data source="& DBPath
sql = "SELECT [username], [time], [times] FROM [sign] WHERE [username] = '" & Replace(username, "'", "''") & "'"
Set rs = CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.Open sql, conn, 1, 3
If rs.EOF And rs.BOF Then
rs.AddNew
rs("username").Value = username
rs("time").Value = Now()
rs("times").Value = 1
rs.Update
b = True
Else
If DateDiff("h", CDate(rs("time").Value), Now()) < 24 Then
b = False
Else
b = True
rs("time").Value = Now()
rs("times").Value = rs("times").Value + 1
rs.Update
End If
End If
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
If b Then
%>
<script language="JavaScript">
alert("签到成功!")
history.go(datecheck.asp)
</script>
<% Else %>
<script language="JavaScript">
alert("今日已经签到!")
history.go(-1)
</script>
<% End if %>