Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm trying to learn php for a task at work. What i need to do is pretty much create an employee inventory form that hold certain information about an employee (their name, phone, email, OS, and MAC address). I would like to have a form to create this. My question is, is there a way to have a form write and save the newly entered information into a file without erasing anything that was there previously. If so, could somebody please help me out?
Thanks,
brds

Yes, but it is not without some potential problems. Using a flat file for data such as this should not be done with caution. If two people were trying to write tot he file at the same time you could corrupt all the data. There are performance issues as well.
Writing the information to the file is not difficult. Just open the file and write the new information to it using some sort of delimination, i.e. comma or tab delimited. The more difficult part is accessing the data. If you were looking for a particulaqr record you need to read through the lines in the file until you found the one you wanted and then parse out the data.
Having said all that, I always prefer to use a MySQL database. The learning curve may be a little more steep than using a flat file, but you can do so much more. However, if you want to use a flat file, here is a tutorial on how to read the data: http://www.designdetector.com/archi...
here is another on how to write to a file: http://www.tizag.com/phpT/filewrite...
Of course, editing a line in the file is a little tricker, but not impossible.
Another option is to use this API which allos you to utilize a text file just like a database: http://www.c-worker.ch/txtdbapi/ind...
Michael J

![]() |
trim characters from php ...
|
Looking for Random Text G...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |