?
Solved

asp execution too slow...

Posted on 2006-07-11
2
Medium Priority
?
324 Views
Last Modified: 2008-02-26
i don't know this page take too much time to execute...
can anyone correct the code so it can load faster....


.......................

<!--#include file="opendb.asp"-->
<%
  Dim strEMail, strPassword
  strUserName = Request.Form("UserName")
  strPassword = Request.Form("Password")

  Dim rsUsers
  set rsUsers = Server.CreateObject("ADODB.Recordset")
  strSQL = "SELECT * FROM Users WHERE FUserName = '" & strUserName & "';"
  rsUsers.Open strSQL, objConn

  If rsUsers.EOF Then                                                         'user not found
    Session("UserName") = Request.Form("UserName")
    If Request.Querystring("SecondTry") = "True" then                    'user's had two goes
      Response.Redirect "join.asp?NotFound=True"                        ' - must register
    Else                                                      'username wrong; password wrong
      Response.Redirect "login.asp?SecondTry=True"                       ' - allow another go
    End If
  Else                                              'one or more users found - check password
    While Not rsUsers.EOF
      If UCase(rsUsers("FPassword")) = UCase(strPassword) Then              'password matched
        Dim strName, strValue
        For Each strField in rsUsers.Fields
          strName = strField.Name                                 'populate session variables
          strValue = strField.value
          Session(strName) = strValue
        Next
        Session("blnValidUser") = True
        If rsUsers("FRemPass") = True Then
          Response.Cookies("PMBVisit")("UserName") = rsUsers("FUserName")
          Response.Cookies("PMBVisit")("NickName") = rsUsers("FNickName")
          Response.Cookies("PMBVisit")("Email") = rsUsers("FEmail")
          Response.Cookies("PMBVisit")("UserID") = rsUsers("FUserID")
        End If
        Response.Redirect "default.asp"                      'successful login
      Else
        rsUsers.MoveNext
      End If
    Wend

    rsUsers.Close
    set rsUsers = Nothing

    objConn.Close
      set objConn = Nothing

    Session("UserName") = Request.Form("UserName")                'if we get this far then...
                                                ' ...password doesn't match any of DB entries
    If Request("SecondTry") = "True" then                                'user's had two goes
      Response.Redirect "register.asp"                                    ' - must reregister
    Else                                                      'username right; password wrong
      Response.Redirect "login.asp?SecondTry=True&WrongPW=True"
                                                                            'allow another go
    End If
  End If

%>
0
Comment
Question by:coolx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 520 total points
ID: 17079560
A while loop may not necessary here...

try:

....
If rsUsers.EOF Then                                                         'user not found
   Session("UserName") = Request.Form("UserName")
    If Request.Querystring("SecondTry") = "True" then                    'user's had two goes
      Response.Redirect "join.asp?NotFound=True"                        ' - must register
    Else                                                      'username wrong; password wrong
      Response.Redirect "login.asp?SecondTry=True"                       ' - allow another go
    End If
  Else                                              'one or more users found - check password
      If UCase(rsUsers("FPassword")) = UCase(strPassword) And rsUsers("FUserName") = strUserName Then              'password and username matched
        Dim strName, strValue
        For Each strField in rsUsers.Fields
          strName = strField.Name                                 'populate session variables
          strValue = strField.value
          Session(strName) = strValue
        Next
        Session("blnValidUser") = True
        If rsUsers("FRemPass") = True Then
          Response.Cookies("PMBVisit")("UserName") = rsUsers("FUserName")
          Response.Cookies("PMBVisit")("NickName") = rsUsers("FNickName")
          Response.Cookies("PMBVisit")("Email") = rsUsers("FEmail")
          Response.Cookies("PMBVisit")("UserID") = rsUsers("FUserID")
        End If
        Response.Redirect "default.asp"                      'successful login
      Else
        Response.Redirect "login.asp?Invalidlogin=True"
      End If
End if
...
0
 

Author Comment

by:coolx
ID: 17087532
this code is a lot faster... can it be a little faster..........
thanks anyways,

 
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question