Solved

asp execution too slow...

Posted on 2006-07-11
2
320 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 50

Accepted Solution

by:
Ryan Chong earned 130 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

808 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