Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

logon page fails

Status
Not open for further replies.

bookouri

IS-IT--Management
Feb 23, 2000
1,464
US
can someone help me fix this asp page?
This is supposed to be a basic logon verification page and everything works fine as long as a valid user name is entered. I can not seem to modify it so that it traps blank user names or usernames that are not in the user table. Ive tried all variations of if elseif endif etc. but can not get the right combination to make it work. Everything else works. If you put in a valid user name it will trap bad passwords/no passwords. But it MUST have a valid user name...

any help would be appreciated..

<%
'Save the entered username and password
'Username = Request.Form(&quot;txtUsername&quot;)

Password = Request.Form(&quot;txtPassword&quot;)

'Build connection with database
set conn = server.CreateObject (&quot;ADODB.Connection&quot;)
conn.Open &quot;Provider=MSDAORA;Data Source=Live;&quot; &_
&quot;User ID=xxx;Password=xxx;&quot;
set rs = server.CreateObject (&quot;ADODB.Recordset&quot;)
'Open recordset with selected username

sqlstring = &quot;SELECT username, password, fullname FROM oms_owner.userlist where username='&quot;& Username &&quot;'&quot;

set rs = conn.execute(sqlstring)

'If there is no record with the entered username, close connection
'and go back to login with QueryString
If rs.recordcount = 0 then
********************************************
rs.close
conn.close
set rs=nothing
set conn=nothing
Response.Redirect(&quot;login.asp?login=namefailed&quot;)
end if
****** here is where I though I had it covered***********

'If entered password is right, close connection and open mainpage
if rs(&quot;password&quot;) = Password then
Session(&quot;name&quot;) = rs(&quot;fullname&quot;)
rs.Close
conn.Close
set rs=nothing
set conn=nothing
Response.Redirect(&quot;default.asp&quot;)
'If entered password is wrong, close connection
'and return to login with QueryString
else
rs.Close
conn.Close
set rs=nothing
set conn=nothing
Response.Redirect(&quot;login.asp?login=passfailed&quot;)
end if
%>
 
You could try if rs.bof and rs.eof = true then
...

Roj
 
you mean like:
if (rs.bof = true and rs.eof = true) then
??
 
No actually it is in this format

if (RS.bof and RS.eof)=&quot;True&quot; then

Seems weird but it works.

Roj
 
just like magic... worked where nothing else would.

and it IS wierd..<G>

thanks

 
just some background:
rs.recordcount only works when you specify a cursor that can move forward and backward (adOpenStatic, for instance). Otherwise, .recordcount will only return -1.

Use .eof to determine the emptiness of default recordsets. Not too much work, and the speed increase is significant. leo

------------
Leo Mendoza
lmendoza@garbersoft.net
 
thanks, I never would have thought of using the
if (RS.bof and RS.eof)=&quot;True&quot; then
form though....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top