dog3
asked on
saving and recurring text files.
I have a Register screen it has a username(Text1), password(Text2), e-mail address (text3. I have got a text file with the username and e-mail address in it(marc.txt). when someone hits submit i want the program to look at the text file (marc.txt) and see if the username, password are real. If so End, If not go to form2. Also then save the password to a text file but call it marc2.hhh. the next person who uses this program will have to enter the password again and again i want it to save to a text file called marc2.hhh but not overwrite the previous saved password.
these are all my points sorry.
these are all my points sorry.
dog3
try this:
' I assume you saved the 3 items in the file in the order of
UserName Password Email
' Check passwaord
Dim lLine as String
Dim lInt as Integer
Dim lUserName as String
Dim lPswd as String
Dim fnum as Integer
Dim lValid as Boolean
lValid = False
fNum = FreeFile
Open "marc.txt" for input as fnum
Do while not EOF(fnum)
Line Input #fnum, lLine
lInt = Instr(lLine, " ")
lUserName = Left(LLine, lInt-1)
lLine = Right(lLine, Len(lLine)-Int)
lInt = Instr(lLine, " ")
lPswd = Left(lLine, lInt)
If lUserName = text1 and lPsWd = Text2 Then
lValid = True
Exit Do
End if
Loop
If lValid = True then
'Do what you do, end?
Else
form2.Show
End If
Let me knoe if you have any questions
Regards
Dalin
try this:
' I assume you saved the 3 items in the file in the order of
UserName Password Email
' Check passwaord
Dim lLine as String
Dim lInt as Integer
Dim lUserName as String
Dim lPswd as String
Dim fnum as Integer
Dim lValid as Boolean
lValid = False
fNum = FreeFile
Open "marc.txt" for input as fnum
Do while not EOF(fnum)
Line Input #fnum, lLine
lInt = Instr(lLine, " ")
lUserName = Left(LLine, lInt-1)
lLine = Right(lLine, Len(lLine)-Int)
lInt = Instr(lLine, " ")
lPswd = Left(lLine, lInt)
If lUserName = text1 and lPsWd = Text2 Then
lValid = True
Exit Do
End if
Loop
If lValid = True then
'Do what you do, end?
Else
form2.Show
End If
Let me knoe if you have any questions
Regards
Dalin
ASKER
Marc.txt has all usernames and domains.
Marc.txt is where i want the password to be stored.
Marc.txt is where i want the password to be stored.
ASKER
no you may of not read my comment after it.
dog3,
I would suggest you put all username/paswd/email in one file (marc.txt) in a format:
UserName Password Email
dog3 yourPass dog3@anyMail.com
Dalin myPswd Dalin_N@MailExcite.com
Whoelse hispsword where@Ever.Com
.
I would suggest you put all username/paswd/email in one file (marc.txt) in a format:
UserName Password Email
dog3 yourPass dog3@anyMail.com
Dalin myPswd Dalin_N@MailExcite.com
Whoelse hispsword where@Ever.Com
.
ASKER
no you may of not read my comment after it.
ASKER
no you see i'm a system admin and i need 1 text file which has username and e-mail
then another which will collect the passwords.
then another which will collect the passwords.
dog3,
Do you mean you don't have your password in marc.txt yet?
Do you mean you don't have your password in marc.txt yet?
ASKER
no you see i'm a system admin and i need 1 text file which has username and e-mail
then another which will collect the passwords.
then another which will collect the passwords.
ASKER
no i do not have the password and want it in marc.hhh
but only in there if the username and e-mail are right.
but only in there if the username and e-mail are right.
ASKER
no i do not have the password and want it in marc.hhh
but only in there if the username and e-mail are right.
but only in there if the username and e-mail are right.
ASKER
the password and username are stored in marc.txt
dog3,
Let me see if I understand you now..
You have a fiel called marc.txt containing username and email
you have a file called marc.hhh tcontaining the password for the users in marc.txt.
When someone login, the/she supply you with a username/password/email via text1/text2/text3
If this username is in marc.txt and he give the right psword, OK
If the userName does not match the password then show form 2.
Please comment
Regards
Let me see if I understand you now..
You have a fiel called marc.txt containing username and email
you have a file called marc.hhh tcontaining the password for the users in marc.txt.
When someone login, the/she supply you with a username/password/email via text1/text2/text3
If this username is in marc.txt and he give the right psword, OK
If the userName does not match the password then show form 2.
Please comment
Regards
This is so confusing!
I would suggest you drop the idea of a txt file and use either the registry or an ini file. Both are much easier to read/write.
I would suggest you drop the idea of a txt file and use either the registry or an ini file. Both are much easier to read/write.
ASKER
Ok here we go.
if username and e-mail address are in marc.txt
marc.hhh is empty.
when a person types in the right username and e-mail
store the password in marc.hhh
-------------------------- Example of Marc.txt--------------
1
2
3
1@2.com for all users there are the same e-mail address.
-------------------------- ---------E nd marc.txt ---------------
if username and e-mail address are in marc.txt
marc.hhh is empty.
when a person types in the right username and e-mail
store the password in marc.hhh
--------------------------
1
2
3
1@2.com for all users there are the same e-mail address.
--------------------------
ASKER
ok you can use ini's
but make marc.txt, marc.ini
and marc.hhh, marc.ini
but make marc.txt, marc.ini
and marc.hhh, marc.ini
dog3,
So you do not want to use the password to validate?
As long as the username and e-mail matches what's in marc.txt, then valid?
But you do not have the userName and it's email in some corresponding way?
I thought your marc.txt file should be:
User1 user1@something.edu
User2 user2@whatever.com
User3 user3@somewhere.org
.
So you do not want to use the password to validate?
As long as the username and e-mail matches what's in marc.txt, then valid?
But you do not have the userName and it's email in some corresponding way?
I thought your marc.txt file should be:
User1 user1@something.edu
User2 user2@whatever.com
User3 user3@somewhere.org
.
Just a suggestion to simplify the issue. Why not manually construct with an editor a sample of what you expect your two files to look like, on first use, and after the second use. Then someone can use these to create and test code for you, if you can't do it your self by then. I would recommend for program simplification that you go with a fixed length typed structure,then use binary file i/o to read/write the type. Also, if storing passwords, use some type of encryption algorithm to avoid security problems.
If your ultimate goal is just to track logons, note that in NT a security log data set is created by NT that can be saved automatically and imported into a database to retain searchable history.
If your ultimate goal is just to track logons, note that in NT a security log data set is created by NT that can be saved automatically and imported into a database to retain searchable history.
ASKER
stuff the e-mail part
all usernames are in marc.ini/txt (whatever)
ok if the e-mail box = "cabra" than it is valid
but if not "cabra" or "username" not valid and go to form2
if boath username and e-mail are valid store password in marc2.hhh/.txt/.ini
ok clear?
Marc.txt contains usernames
Marc2.txt contains the valid users passwords
and the e-mail box HAS to equal cabra lower caps.
all usernames are in marc.ini/txt (whatever)
ok if the e-mail box = "cabra" than it is valid
but if not "cabra" or "username" not valid and go to form2
if boath username and e-mail are valid store password in marc2.hhh/.txt/.ini
ok clear?
Marc.txt contains usernames
Marc2.txt contains the valid users passwords
and the e-mail box HAS to equal cabra lower caps.
let me see if I understand...
'Check valid logon
Dim lUserName as String
Dim lPswd as String
Dim fnum as Integer
Dim lValid as Boolean
dim fPsNum as Integer
lValid = False
If text3 = "cabra" then
fNum = FreeFile
Open "marc.txt" for input as fnum
Do while not EOF(fnum)
Line Input #fnum, lUserName
If lUserName = text1
lValid = True
Exit Do
End if
Loop
Close #Fnum
If lValid = True then
'Store the password
lPswd = Text2
fNum = FreeFile
Open "Marc2.txt" for Append as #fNum
Print #FNum, lPswd
Close #FNum
Else
form2.Show
End If
'Check valid logon
Dim lUserName as String
Dim lPswd as String
Dim fnum as Integer
Dim lValid as Boolean
dim fPsNum as Integer
lValid = False
If text3 = "cabra" then
fNum = FreeFile
Open "marc.txt" for input as fnum
Do while not EOF(fnum)
Line Input #fnum, lUserName
If lUserName = text1
lValid = True
Exit Do
End if
Loop
Close #Fnum
If lValid = True then
'Store the password
lPswd = Text2
fNum = FreeFile
Open "Marc2.txt" for Append as #fNum
Print #FNum, lPswd
Close #FNum
Else
form2.Show
End If
I made a similar logon screen with Username/Password. I stored the names and passwords in a password locked .mdb. When the user submitted each I scanned the mdb for the username tested to see if the password matched, if it did...Welcome. However, I realize this may not be the solution for you. Just a thought.
Regards,
Sekans
Regards,
Sekans
ASKER
i can't get this to work could you e-mail the whole project including the 2 text files to me then i wil give you the points.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!!!
dog3,
1. You can read the text file into a ftring variable since you do not need to show it.
Dim lString as String
Dim lLine as String
Dim fNum as Integer
Open "YourTxtFileWithPath.txt" for input as fnum
Do while not EOF(fnum)
Line Input #fnum, lLine
lString = lString & lLine
Loop
Close #Fnum
Now lString has your txt File.
I was not clear on your 2nd question, can you clearify?
Regards
Dalin
>Thanks for doing that code it realy well.
>i was wondering if you knew how to load a text file into a hidden text =
>box?
>
>is there a way which you can type */www.txt ?
>where the star is it means where ever the program is installed
>eg d:\1\ is where it is installed so www.txt is in d:\1\
> c:\2\ is where it is installed so www.txt is in c:\2\
>ect please tell me=20
>thx
>
>
1. You can read the text file into a ftring variable since you do not need to show it.
Dim lString as String
Dim lLine as String
Dim fNum as Integer
Open "YourTxtFileWithPath.txt" for input as fnum
Do while not EOF(fnum)
Line Input #fnum, lLine
lString = lString & lLine
Loop
Close #Fnum
Now lString has your txt File.
I was not clear on your 2nd question, can you clearify?
Regards
Dalin
>Thanks for doing that code it realy well.
>i was wondering if you knew how to load a text file into a hidden text =
>box?
>
>is there a way which you can type */www.txt ?
>where the star is it means where ever the program is installed
>eg d:\1\ is where it is installed so www.txt is in d:\1\
> c:\2\ is where it is installed so www.txt is in c:\2\
>ect please tell me=20
>thx
>
>
paul.txt for user paul, ... ?
Do you have marc.txt for all users ?
Do you have one or more users ?
The password is in marc.txt (with name & e-mail) ?