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

searching and removing a line in a txt file?

Status
Not open for further replies.

cleansedbb

Technical User
Feb 11, 2002
95
US
What I'm trying to do is assign temp passwords to go to a form page to fill out info and on submit the temp account is gone and I'll take the email and give a new perm account to the individual.

I have a script that reads the lines into vars and then checks the TEMP usernames and password against it.

the users.txt file looks like this

# | name | password
1 temp1 pass1
2 temp2 pass2

right now I just use a form to write accounts into the file but I have to deletem them manually.

I want to have them deleted after one login.

kind of a submit on formpage deletes that user from the file
 
I would open the old file and write the contents to a new one, skipping the line you wanted to delete. Then delete the old file and rename the old file to the new file's name.

Keep in mind that that you may need to lock the files during this operation and have scripts that depend on that file check for locks. This would improve data consistency.

The much easier way would be to throw the credentials into a database server, like MySQL. Want the best answers? Ask the best questions: TANSTAAFL!
 
if I convert to a mysql db. how easy is it to drop a line?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top