Click to See Complete Forum and Search --> : login problem on ASP page


IanBaker
11-04-2003, 09:33 AM
Hi

I'm having hassles with a login fuinction on my site

What happens is:
The user fills in a form which populates a simple text file/database. They then login using their name and password. Its not working though, from what I can see, the password is including all the fields

Please help

regards
Ian

this is the write line command:
Set writefile = fs.OpenTextFile(filename, 8, True)
writefile.writeline(Request.Form("user_name") & "=" & choice & "," & Request.Form("job_title") & "," & Request.Form("company_name") & "," & Request.Form("address1") & "," & Request.Form("address2") & "," & Request.Form("address3") & "," & Request.Form("email_address") & "," & Request.Form("phone_number"))
writefile.Close

this is the login script:


Sub CheckLogin

redim arrStr(-1)
dim arrTmp

Set fs = CreateObject("Scripting.FileSystemObject")
filename=server.mappath("../../data/bl_survey_2003/survey_2003.bal")
Set readfile=fs.OpenTextFile(filename,1,False)
i = 0
Do until readfile.AtEndOfStream
redim preserve arrStr(i)
arrStr(i) = readfile.readline
i = i + 1
Loop
readfile.close
set readfile=nothing

For a=0 to Ubound(arrStr)
If Instr(arrStr(a), "=") > 0 Then
arrTmp = split(arrStr(a), "=")
If LCase(Request.Form("username")) = trim(LCase(arrTmp(0))) And LCase(Request.Form("userpwd")) = trim(LCase(arrTmp(1))) Then
Session("UserLoggedIn") = "true"
Exit For
End If
End if
Next

rdoekes
11-04-2003, 10:01 AM
Originally posted by IanBaker

Do until readfile.AtEndOfStream
redim preserve arrStr(i)
arrStr(i) = readfile.readline
i = i + 1
Loop

I noticed when you read you do not split on ",". Maybe this works.

Do Until readFile.AtEndOfStream
arrStr = Split(readFile.readline, ",")
For i = 0 To UBound(splitArray)
If InStr(arrStr(i), "=") Then
arrTemp= Split(arrStr(i), "=")
If LCase(Request.Form("username")) = trim(LCase(arrTemp (0))) And _
LCase(Request.Form("userpwd")) = trim(LCase(arrTmp(1))) Then
Session("UserLoggedIn") = "true"

Exit For
Exit Do
For
Loop
Have not tested this. Hope this will work
-Rogier Doekes

IanBaker
11-04-2003, 10:40 AM
hi Rogier

no luck - thanks for trying to help

the page refuses to load when i put this code in