How do you wite and read files in PHP?

LadyBug

New member
I have to create a contact form, create a php script that writes the data , create a pho script that reads the data This is my assignment: I have been working on this for WEEKS and still cannot get it to work...

Applications with low volume and short life span can be easily handled with a simple file application. The file created can be read with any text editor. You will want to be careful that all data is separated, and that each data record is on a separate line in the text file.
Reading the file and showing the data on a response page requires that you break apart or ‘explode’ each record in the file.
Project
You will create a Telephone Directory Application to save entries into a single text file. Your HTML form will collect the following data items:
1. Last Name
2. First Name
3. Street Address
4. City
5. State
6. Zip
7. Area code
8. Phone Number
Your PHP program will take the data submitted by the form, using string functions assemble one record to be written to the file for each Telephone Directory entry that is submitted.
The data will be written in a comma delimited line of information terminated by a new line character and will be appended to the telephone data file. When multiple entries have been made to the form, the file should contain all the stored items on separate lines.
Be sure to ‘close’ the file when the data has been written.
In a new program you will open the file to ‘read the data’ and list all the items currently in the file. Your PHP program will present the data in a format that is easily readable, not in the manner it was ‘stored’. Provide a link or button to ‘run’ this program on the HTML form page.
 
Back
Top