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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If request.form = blah blah... else.. statements slow down, speed help 1

Status
Not open for further replies.

2cxc

Programmer
Aug 29, 2003
245
CA
I have a page of login info that redirect to a page associated with the login info, so i have a page.asp for each unique login. The page is getting long and slow, I know arrays are faster that requests...correct? if so how could i speed this up:
Code:
If Request.Form("login") = "sen" AND Request.Form("password") = "2r3ez9" Then
Session("login") = "1"
	Response.Redirect "sen.asp"
ElseIf Request.Form("login") = "BUTLER" AND Request.Form("password") = "1LePAGE2" Then
Session("login") = "1"
	Response.Redirect "butler.asp"
ElseIf Request.Form("login") = "drory" AND Request.Form("password") = "amechia" Then
	Session("login") = "1"
	Response.Redirect "drory.asp"
ElseIf Request.Form("login") = "tavares" AND Request.Form("password") = "1q2w3e" Then
	Session("login") = "1"
	Response.Redirect "tavares.asp"
ElseIf Request.Form("login") = "gill" AND Request.Form("password") = "12qw" Then
	Session("login") = "1"
	Response.Redirect "gill.asp"
ElseIf Request.Form("login") = "donde" AND Request.Form("password") = "123qwe" Then
	Session("login") = "1"
	Response.Redirect "donde.asp"
ElseIf Request.Form("login") = "abrams" AND Request.Form("password") = "1a2b3c" Then
	Session("login") = "1"
	Response.Redirect "abrams.asp"
ElseIf Request.Form("login") = "baalbaki" AND Request.Form("password") = "1qaz2wsx" Then
	Session("login") = "1"
	Response.Redirect "baalbaki.asp"
ElseIf Request.Form("login") = "park" AND Request.Form("password") = "1q2w3" Then
	Session("login") = "1"
	Response.Redirect "park.asp"
ElseIf Request.Form("login") = "sohn" AND Request.Form("password") = "11qq22ww" Then
	Session("login") = "1"
	Response.Redirect "sohn.asp"
ElseIf Request.Form("login") = "ORUNCAK" AND Request.Form("password") = "1QAZ2WSX" Then
	Session("login") = "1"
	Response.Redirect "oruncak.asp"
ElseIf Request.Form("login") = "Phil" AND Request.Form("password") = "2W4R6Y" Then
	Session("login") = "1"
	Response.Redirect "phil.asp"	
ElseIf Request.Form("login") = "paskov" AND Request.Form("password") = "zaq1xsw2" Then
	Session("login") = "1"
	Response.Redirect "paskov.asp"
ElseIf Request.Form("login") = "Ajmera" AND Request.Form("password") = "11qq22ww" Then
	Session("login") = "1"
	Response.Redirect "pajmera.asp"
ElseIf Request.Form("login") = "CANAM" AND Request.Form("password") = "1A2B3C" Then
	Session("login") = "1"
	Response.Redirect "canam.asp"
ElseIf Request.Form("login") = "NewWorld" AND Request.Form("password") = "1qaz" Then
	Session("login") = "1"
	Response.Redirect "newworld.asp"
ElseIf Request.Form("login") = "Bala" AND Request.Form("password") = "1bala2" Then
	Session("login") = "1"
	Response.Redirect "bala.asp"
ElseIf Request.Form("login") = "Coldwell" AND Request.Form("password") = "1Q2W3E" Then
	Session("login") = "1"
	Response.Redirect "coldwell.asp"
ElseIf Request.Form("login") = "Russo" AND Request.Form("password") = "1Russo2" Then
	Session("login") = "1"
	Response.Redirect "russo.asp"
ElseIf Request.Form("login") = "Coates" AND Request.Form("password") = "Coates246" Then
	Session("login") = "1"
	Response.Redirect "coates.asp"
ElseIf Request.Form("login") = "Transport" AND Request.Form("password") = "1help2" Then
	Session("login") = "1"
	Response.Redirect "transporthelp.asp"
ElseIf Request.Form("login") = "RE/MAX" AND Request.Form("password") = "4sale" Then
	Session("login") = "1"
	Response.Redirect "mississauga4sale.asp"
ElseIf Request.Form("login") = "AUNGER" AND Request.Form("password") = "1BECKWITH2" Then
	Session("login") = "1"
	Response.Redirect "hitchins.asp"
ElseIf Request.Form("login") = "Baranov" AND Request.Form("password") = "1q2w3e4r" Then
	Session("login") = "1"
	Response.Redirect "baranov.asp"
ElseIf Request.Form("login") = "Sutton" AND Request.Form("password") = "1Bihr2" Then
	Session("login") = "1"
	Response.Redirect "bihr.asp"
Else
	Response.Redirect "login.asp"
End If
 
why dont you write all this info, Username, password and redirect page into a text file and use ado to read and redirect based on the results from text file?

Or you can use a database to do the same





The solution is simple, the problem is complex.

 
why dont you use CASE statement instead of going ifs and elseifs
 
Ecreations is absolutely correct

forget the flat file as the list is that long. that is why god invented the database and all the great things it can do for us.

a one line
SELECT * FROM userInformation WHERE name='" & request.form("name") & "' AND password ='" & request.form("password") & "'"

can give you all that if statement can


_____________________________________________________________________
onpnt2.gif
[sub]
Hakuna matata!!
[/sub]
 
I wish I could use a database but (and this may sound strange) but the server folder permissions need for a db, can't be done.

Ecreations, ado sounds neat, always willing to learn something new, as long as the manual updating is as non-time consuming as adding to the if statemets page.

have any links on it that would apply to my sitch?
 
w3schools is the answer toi all reference questions :) I still use it occasionally, here is a link to their ADO section:

While all of their examples apply to MSAccess db's, you should be able to specify a link toa CSV file by just altering the connection string you use.

Here is a link to a tutorial from 4GuysFromRolla:


Hope this helps
-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
if using a database (probably your best method) is out of the question, and you are not able to read/write to textfiles, consider using some dictionary objects that would, at the very least, be somewhat easier to troubleshoot and maintain over time...

Code:
Dim objLogins
Set objLogins = Server.CreateObject("Scripting.Dictionary")
objLogins.Add "sen"      , "2r3ez9"
objLogins.Add "butler"   , "1LePAGE2"
objLogins.Add "drory"    , "amechia"
objLogins.Add "tavares"  , "1q2w3e"
... etc ...

If objLogins.Exists(Request.Form("login")) Then
    If objLogins(Request.Form("login")) = Request.Form("password") Then
        Session("login") = "1"
        Response.Redirect Request.Form("login") & ".asp"
    Else
        Response.Write "bad password!"
    End If
Else
    Response.Write "user does not exist!"
End If

good luck!
-f!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top