In this exercise, you'll be developing a full-featured application to create digital greeting cards or eCards and store them in a simple database. Users of the application will be able to browse images on their file system to use with the greeting card and save it along with a simple greeting. The project can be divided into three main tasks/pages:
Each of the files listed above is provided in the attached download named incomplete_code.zip. Some of the code is already written; in fact, you can run this skeleton project as is, although it won't do anything interesting until you complete the implementation. The sections below list the incomplete functions and how to write the code to achieve the end result described above. A full implementation (complete_code.zip) is attached as well so you can compare your end result with ours, but no peeking until the end!
Part AIn this section, you'll be completing image_select.php. You'll be exercising the concepts covered in PHP Basics by writing code to access the file system and retrieve a listing of all files in a directory. The code for presenting the images to the user is already complete. Before you begin, look at the code that has already been written to get a feeling for how it works. The code currently consists of a set of functions (be sure to sneak another peek at the PHP Basics sheet if you need a refresher on how functions work in PHP) followed by a single invocation at the very bottom of the script, which executes the This is the function you will have to implement. Right now, it just returns function fetch_images_from_file_system() You need to write the code, using the documentation provided in the PHP Basics sheet, to retrieve the list of files in the provided images directory. You can test if you have the right output by passing the array returned from the function into the print debug function Array
Part BIn this section, you'll be working on create_card.php, which accepts a URL to an image via the query string and displays a form for users to enter a custom greeting and an email address to send the card to. For this part, you will use the special arrays discussed in the sheet to access the image passed in through the URL. The image is accessed directly in function main() You should change this so that when the following URL is submitted, you see the image below it displayed onscreen: http://localhost/WebDevEDU/php/exercise1/complete_code/create_card.php?img=_images%2F3191747133_99f4d14198.jpg Part CIn this section, you'll complete send_card.php. This script is responsible for saving the created card in the database and sending the email to the recipient specified in the previous script. You'll be completing the get_card_object function which currently returns a null object. You should create a new card instance (refer to the section on classes in the PHP Basics sheet) and set its properties accordingly given the parameters passed in to the script. |