Re: Question about login script
- From: Vijay Pote (MCP, MCAD, MCSD-In Dot Net) <VijayPoteMCPMCADMCSDInDotNet@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 5 Aug 2005 07:07:06 -0700
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
> > > %>
> > >
> >
> >
> >
.
- References:
- Question about login script
- From: Joe
- Re: Question about login script
- From: Tom . PesterDELETETHISSS
- Re: Question about login script
- From: Joe
- Question about login script
- Prev by Date: Load v1.1 framework for ASP page with v2.0 installed on the same machine
- Next by Date: Encrytion causing error
- Previous by thread: Re: Question about login script
- Next by thread: Temporary ASP.NET Files ?
- Index(es):
Relevant Pages
|