Solved

asp execution too slow...

Posted on 2006-07-11
2
317 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
2 Comments
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 130 total points
Comment Utility
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
Comment Utility
this code is a lot faster... can it be a little faster..........
thanks anyways,

 
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video teaches users how to migrate an existing Wordpress website to a new domain.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now