?
Solved

asp execution too slow...

Posted on 2006-07-11
2
Medium Priority
?
328 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 54

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

862 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