Re: Question about login script



Hi Joe,

I hope I solved it. Try

AND Active = true

instead of

AND Active = 1

Let me know if you have any more questions..

Cheers,
Tom Pester

Yes when I used objRS.RecordCount, I got -1, so I changed the
statement from

objRS.Open strSQL, objConn, adOpenForwardOnly, adLockReadOnly,
adCmdText

to

objRS.Open strSQL, objConn, 3, 3, adCmdText

with

strSQL = "SELECT * FROM dndusers " & "WHERE E_Mail='" &
Request.Form("txtEmail") & "' AND Password = '" &
Request.Form("txtUserPass") & "';"

and I got  recordcount as 1.

But when I added Active = 1 to SQL statement and run

strSQL = "SELECT * FROM dndusers " & "WHERE E_Mail='" &
Request.Form("txtEmail") & "' AND Password = '" &
Request.Form("txtUserPass") & "' AND Active = 1 ;"

the recordcount is 0

this is why the I keep getting redirected to login page -
default.asp?pw=0

Is something wrong with my SQL statement?

I checked the 'Active' which is a Yes/No data field in MS Access DB is
checked that is set to 1, so I should get recordcount as 1 instead of
0.

Can someone help me locate the error. My head is not working anymore.

Thanks,

Joe

"Tom.PesterDELETETHISSS@xxxxxxxxxx" wrote:

- Are you sure a record is returned? Check this be printing the
objRS.Recordcount to the page. It should be 1 of course.

- Are you sure that Response.Redirect("default.asp?pw=0") is executed
each time? Maybe the good redirect happens but some other code in
another page does a redirect to 'default.asp?pw=0' and you think this
page did that.

I hope it helps...

Cheers,
Tom Pester
Hi,

I have a login page.  Where user enters an email and password. Then
I;m checking if user account is active or not. Before a user can
login, he needs to activate his account.  If the account is active
then Active field is set to yes (1) otherwise to no (0).

If the user's account is active then I check whether this is user's
first visit or not. If it is user's first visit then I redirect user
to 'newuser.asp' page otherwise to 'returnuser.asp'.

If the user's account is not active then I send the user to login
page with 'default.asp?pw=0'

For some reason the SQL statement

strSQL = "SELECT * FROM testusers " & "WHERE E_Mail='" &
Request.Form("txtEmail") & "' AND Password = '" &
Request.Form("txtUserPass") & "' AND Active = 1 ;"

is not working because I can see that the user's account is active,
email and password all exist in the database but the script keeps
directing the user to loginpage as if the record doesn't exist.

The SQL query that above statemtn produces is,

SELECT * FROM testusers WHERE E_Mail='green2004@xxxxxxxxxx' AND
Password = 'joegreen' AND Active = 1 ;

I am not able to find the mistake I am making. Can someone help me
please.

Thanks,

Joe

<%
'Using a DSN connection.
Dim objConn
Dim objRS
Set objConn = Server.CreateObject("ADODB.Connection")
'objConn.ConnectionString = "DSN=PKMSolutionEval"
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=E:\ databases\test.mdb;"
Set objRS=Server.CreateObject("ADODB.Recordset")
'objRS.Open "testusers", objConn
strSQL = "SELECT * FROM testusers " & "WHERE E_Mail='" &
Request.Form("txtEmail") & "' AND Password = '" &
Request.Form("txtUserPass")
& "' AND Active = 1 ;"
objRS.Open strSQL, objConn, adOpenForwardOnly, adLockReadOnly,
adCmdText
If Not objRS.EOF And Not objRS.BOF Then
If objRS.Fields("First_Visit") = "True" Then
'first time visitor
strSQL = "UPDATE dndusers SET First_Visit = 0 WHERE E_Mail='" &
Request.Form("txtEmail") & "' AND Password = '" &
Request.Form("txtUserPass")
& "';"
Set updateCmd = Server.CreateObject("ADODB.Command")
With updateCmd
.ActiveConnection = objConn
.CommandText = strSQL
.Execute
End With
objRS.Close()
objConn.Close()
Set objConn = Nothing
Response.Redirect("newuser.asp")
Else
'retruning user
objRS.Close()
objConn.Close()
Set objConn = Nothing
Response.Redirect("returnuser.asp")
End If
Else
'user don't exisit
objRS.Close()
objConn.Close()
Set objConn = Nothing
Response.Redirect("default.asp?pw=0")
End If

objConn.Close()
Set objConn = Nothing
%>


.



Relevant Pages

  • Re: Question about login script
    ... objRS.Open strSQL, objConn, adOpenForwardOnly, adLockReadOnly, ... objRS.Open strSQL, objConn, 3, 3, adCmdText ... >> I;m checking if user account is active or not. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: "Transaction deadlocked" problem
    ... > as the deadlock victim. ... > I tried the following syntax on my recordset Opens: ... > objRec.Open strSQL, objConn, adOpenForwardOnly, adLockReadOnly ...
    (microsoft.public.scripting.vbscript)
  • Problem reading Access database from ASP
    ... Dim objConn ... Dim strSQL ... Set objConn = Server.CreateObject ...
    (microsoft.public.vstudio.development)
  • Re: Newbie needs help with "yes/no" field
    ... > I get an error message saying "No value given for one or more required ... > strSQL, I see all the variables have values. ... > Dim objConn ... > objRS.Open strSQL, objConn, adOpenForwardOnly, adLockReadOnly, adCmdText ...
    (microsoft.public.inetserver.asp.db)
  • Re: ASP and Access SQL Problem
    ... I am assuming that objConn is opened before this code is hit. ... objConn.Execute strSQL ... And do not use the recordset at all. ...
    (microsoft.public.inetserver.asp.general)