Hi all,
Ive got a asp page that checks login that is giving me some problems.
The page is called after login. It checks access db for a valid record. Does this fine. I then wish to write the login to another table to enable tracking of clients. The code I am using is just not working. Nothing is being written to the table. I have tried 2 methods of writing to the db , using INSERT and conn.execute and a RS SELECT with update. Niether are working.
I think this is something that fresh eyes may solve.
Ill hasten to say that this is a new table I have created. So as no confusion , my field names in the table are in capital letter and so is the table name PNETLOGGED. I resorted to capitalising as my original table used lower and upper case. I thought this might confuse .. not sure.
Anyway. The code is below. section that is not working is the RSlogged.Open with RSlogged.Update... the INSERT code that i used is also commented out there.
(ps I am not getting any errors either..... and the login check is working properly so i know accessing the table.... code is actually the same as registration code.. all i have done though that is different is build a new table and change the field names in the code below .. this is why absolutely baffled and wander about the table.)
This is really buggin me. Ive been looking at for hours now and just cant get through it.
Any help or ideas would really be appreciated.
cheers.
Code:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Dat a Source=" & Server.MapPath("db/database.mdb")
dim Conn,RS,RSlogged,SQL,userEmail
username = request("username")
password = request("password")
SQL = "SELECT * FROM tb_user WHERE is_ava = 1 and loginName = '" & username & "' AND password = '" & password & "'"
Set RS = Conn.Execute(SQL)
if not (RS.EOF and RS.BOF) then
' User Login Success
Session("userID") = RS("ID")
Session("loginname") = RS("loginname")
userEmail = RS("emailAddress")
if RS("privilege") = 2 then
Session("adminID") = 2
end if
Conn.close
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Dat a Source=" & Server.MapPath("db/database.mdb")
'Set RSlogged = Server.CreateObject("ADODB.RecordSet")
RSlogged.Open "Select * FROM PNETLOGGED", Conn, adOpenDynamic, adLockPessimistic, adCMDText
RSlogged.AddNew
RSlogged("PNETID") = "1"
RSlogged("PNETUSERNAME") = "Stephen"
RSlogged("PNETEMAIL") = "ssmason@gmail.com"
RSlogged.Update
'insertSQL = "INSERT INTO pnets_logged(pnetID, loginName, emailAddress) values('"&Session("userID")&"', '"&Session("loginname")&"', '"&userEmail&"')"
'conn.Execute(insertSQL)
Response.Redirect "PNETindex.asp"
else
' Login Fail
response.write ("<script>alert('Invalid username or password. Please try again!');window.history.back();</script>")
end if
%>
<%
Conn.close
set RS = nothing
RSlogged = nothing
set Conn = nothing
%>
|