Re: Question about login script



Hi Joe,

the best thing would be debug the page with response.write and you will get
some clue where its going wrong.

Vijay Pote

"Joe" wrote:

> 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: User Account - Cannot Access
    ... You can just copy the profile from one to the other. ... Joe wrote: ... Why would her login be corrupted, if she has the former profile moved ... Flip her account to power user. ...
    (microsoft.public.windows.server.sbs)
  • Re: Win XP PRO User Accounts????
    ... I have a second account of her name. ... "Joe" wrote in message ... > name when there are two users with the same login on the same machine. ... > Either because it exists on the domain or just on the local machine. ...
    (microsoft.public.windowsxp.help_and_support)
  • Question about login script
    ... I have a login page. ... checking if user account is active or not. ... For some reason the SQL statement ... user to loginpage as if the record doesn’t exist. ...
    (microsoft.public.inetserver.asp.db)
  • Question about login script
    ... I have a login page. ... checking if user account is active or not. ... For some reason the SQL statement ... user to loginpage as if the record doesn’t exist. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Users wexpired passwords(non-blank) + PASSWD_NOTREQD = Access ???
    ... That's why I suggested testing it. ... required to LOGIN, its simply like Joe said, the account isn't ... This is what I was thinking and I think Joe pretty much confirmed it. ...
    (microsoft.public.windows.server.active_directory)