10. juni 2002 - 10:44Der er
2 kommentarer og 1 løsning
Login info
Jeg vil gerne have når folk logger ind at så den skriver i db`en hva tidspunkt og dato de logger ind. men jeg ved ikke hvordan jeg skriver det i login filen.
Nogen der kan hjælpe?
her er login scriptet.
<% Dim sql,rsUser,username,password,page,stayloggedin,LConnectString,lconn,sqlflag
'Grab the submitted variables (page is the page they've come from, set by the hidden variable at the login box) username = Request.Form("username") password = Request.Form("password") page = Request.Form("page") stayloggedin = Request.Form("stayloggedin")
'Check no s**t is trying to hack in using SQL commands if InStr(username, "'") or InStr(username, """") or InStr(username, "=") or InStr(password, "'") or InStr(password, """") or InStr(password, "=") then sqlflag = True end if
if sqlflag <> true then 'Open connection %> <!--#include file="conn.asp"--> <%
'Get a recordset corresponding to the submitted username and password sql = "SELECT username FROM users WHERE username = '" & username & "' AND password = '" & password & "'" Set rsUser = Server.CreateObject("ADODB.Recordset") rsUser.Open sql, conn, 3, 3
'If there was a valid recordset there, then send them back to the page they came from, with the username cookie set If (not rsUser.BOF) and (not rsUser.EOF) and sqlflag <> True then Response.Cookies("username") = rsUser("username") 'If the user wants to stay logged in all the time, then we'll set the cookie with a far-away expiry date if stayloggedin = "yes" then Response.Cookies("username").expires = #1/1/2010#
end if rsUser.close set rsUser = nothing conn.close set conn = nothing Response.Redirect(page) end if
'Otherwise, display an invalid entry screen rsUser.close set rsUser = nothing conn.close set conn = nothing
else end if %>
<font size="3" face="Garamond">Forkert brugernavn eller password </font> <p align="center">
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
set DB = server.createobject("ADODB.connection") path = Server.MapPath("db.mdb") DB.Open "DBQ="& path &";DefaultDir="& path & ";Driver={Microsoft Access Driver (*.mdb)}" End Sub
Function GetRecords(grSQL) Dim tmpRS Set tmpRS = Server.CreateObject("ADODB.RecordSet") tmpRS.Open grSQL, DB, 3, 1 Set GetRecords = tmpRS Set tmpRS = Nothing grSQL = "" End Function
Function UnQuote(WorkStr) UnQuote = Replace(WorkStr, "'", "''") End Function
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then tLogin = Request.Form("login") tPassword = Request.Form("password") OpenDatabase
Set RS = GetRecords("SELECT ID, Navn, AntalLogins FROM login WHERE Login='" & UnQuote(tLogin) & "' AND Password='" & UnQuote(tPassword) & "'")
If RS.RecordCount = 1 Then Session("UserID") = RS("ID") Session("Navn") = RS("Navn") DB.Execute "INSERT INTO tblLoginInfo (UserId,LoginDato,IP) VALUES (" & RS("ID") & ",'" & Now & "','" & Request.ServerVariables("REMOTE_ADDR") & "')" DB.Execute "UPDATE kontakt SET AntalLogins=" & RS("AntalLogins") + 1 & " WHERE ID=" & RS("ID") RS.Close Set RS = Nothing DB.Close Set DB = Nothing Else Response.Write "Det indtastede brugernavn og password stemmer ikke overens." End If End If %>
Så opretter du en tabel som hedder tblLoginInfo som indholder. UserId, LoginDato, og ip.
I den tabel som du har dine bruger i, opretter du en kolonner som hedder AntalLogins - så kan du også se hvor mange gange de logger ind.
Jeg kører nu, men er hjemme igen om en halv timestid, så bare send det.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.