Homework assignment #5

In this assignment you will continue working on the script that receives an image file and information about it from the picture uploading form. In this assignment you should do two separate things.

First of all, you need to add some PHP code to the code you have developed for the previous assignment. The script that receives data from the form should not only confirm receiving of the image by displaying information about the file, but also save the obtained information into a special file named images_info.txt. This will be a pure text file each line of which will contain information about one image. One line of the file has the following format:

c  filename  title  date  time  camera  comments
where All fields are separated with tabulation symbol.

Please note that one record takes exactly one line of the file. You cannot occupy two lines of the file with information about one file. In particular, this means that you should take care about the comments field because it may contain more that one line and thus has a new line symbol inside. (Hint: use str_replace() function or preg_replace() function to make the substitution.)

This script should also display a link to the second PHP script you need to develop. This second script should do an easy job. You need to read all lines from the images_info.txt file and display it as a table. Don't forget to display titles for all the columns. You do not need to show the very first field in the line, but you should take it into consideration and do not display the records that are removed (have X in this position). You also should add one more column to the table. Each cell of this column will contain a small delete button that is to execute another PHP script (which you do not need to develop yet) passing the name of the file as an argument. The code for this, for example, can look like this:
<img src="delete.gif" onclick="location.href='delete.php?fname=oldimage.jpg';" style="cursor:hand;">
In this assignment you don't have to make this button work.

The page generated by this script should also have a link to the picture uploading form and a link to the slide show page.

Do not forget to update your home page and include a link to the updated picture uploading form as the solution to this assignment.