CMSC 210
Spring 2017
Exercise
04/05/2017
PhP and Files
Due: end of class 

Assignment:   (worth 5 exercise points)     

0)    On the server, in your cgi-bin directory, copy the following file:

cp  /home/scottmce/210files/fruits1.txt   .      (note the period)


Create a file called  Lists.php   that will produce a web page as follows:
  • HTML title:   "Fruit list from file"
  • background color:  some shade of pink
  • body contents:   
    • an HTML unordered list containing the name of all of the fruits in the file   fruits1.txt
      • Note that if the contents of that file were to change, the next time the page is loaded, the page should have new contents.
      • Test this page at:     http://cs.longwood.edu/~YOURUSERID/cgi-bi/Lists.php
    • an image of your favorite fruit

1)     Modify the PhP file above to read the file:   /home/scottmce/210files/fruits2.txt   instead of the one you copied.    

DO NOT COPY THE FILE TO YOUR DIRECTORY, BUT READ IT DIRECTLY FROM MINE.

There is also a fruits3.txt file in that directory you might wish to test out.


2)  Create a webpage (to be published at:  http://cs.longwood.edu/~youruserid/210/Fruit.html  )

This page should have a form with two items:
1)   a place to enter the name of a fruit
2)  a submit button

When the submit button is hit, the script from number 1 should be called.

Modify the script from number 1 as follows:
i)  if the fruit entered is in the list, make that fruit BOLD, but the rest remain unchanged.

For instance:

  • apple
  • papaya
  • mango
  • blueberry
  • banana
  • cherry

ii)   if the fruit entered is NOT in the list, put a statement saying that the fruit was not in the list.

For instance:

  • apple
  • papaya
  • mango
  • blueberry
  • banana
  • cherry
Your entered fruit was not in the list.





Handin:

http://cs.longwood.edu/~youruserid/210/Fruit.html