Programming Exercise I:
A Simple Online Bookstore Using LAMP Technologies

(Industry-Level, Second-to-None Comprehensive Specifications)

Absolutely no copying others’ works

Development Requirements
When start developing the exercise, follow the two requirements below:

Soft Due Date and Submission Methods
On or before Wednesday, February 22, 2017 in class and have completed the following tasks: Since related topics may not be covered completely by the due date, no penalty will be applied if submitted after the due date. However, you may lag behind if you are not able to submit it by then.

Note that you are allowed to use any languages and tools for this exercise, but the exams will focus on LAMP and AJAX technologies unless otherwise specified.

This exercise includes activities of business-to-business (B2B) and business-to-consumer (B2C). B2B describes commerce transactions between businesses, such as between a manufacturer and a wholesaler, or between a wholesaler and a retailer. XML (eXtensible Markup Language) defines a standard way of encoding the structure of information in plain text format. With XML, financial information can be exchanged over the Internet conveniently. Whereas B2C refers to transactions conducted directly between a company and consumers.

Objectives and Procedures
This exercise is to design and implement a simple online database-driven bookstore based on a B2B business model in addition to the B2C model. The bookstore has an agreement with the suppliers about the format of the book list in XML and together they come up with a DTD (Document Type Definition). The bookstore implements the system based on the DTD and uploads book lists from the suppliers to its system. The owners then manage their books via their store website. In addition, customers can purchase books via the website. This exercise has students use the LAMP technologies and learn how to integrate XML into their systems and databases. It includes the following features: XML data to MySQL database, data searching and ranking, data processing and management, etc. The online bookstore includes the following three kinds of users:

Exercise Requirements
The bookstore includes the following features:

An Example of Web System Interfaces
Note that this example is not related to this exercise. It is only to show how to display web pages.

An Example of File Uploading
The following interface, upload.html in html or txt, is used to upload an XML file:

  Upload a Book List.
  A book list (XML):



Most web languages allow file uploading. The above example uses the PHP script, upload.php, which requires a directory at /home/wenchen/public_html/course/457/exercise/1/upload/ to store the uploaded files. Note that you may need to open the folder by using the following command:
     chmod 777 upload/
so the Web can write the files to the folder.

    if ( $_POST['act'] == "Upload" ) {
      header( "Content-type: text/html" );
      if ( ( $_FILES[file][type] == "text/xml" ) &&
           ( $_FILES[file][size] < 50000 ) ) {
        if ( $_FILES[file][error] <= 0 ) {
          echo "Upload: <em>" . $_FILES[file][name] . "</em>";
          echo "Type: <em>" . $_FILES[file][type] . "</em>";
          echo "Size: <em>" . ceil( $_FILES[file][size] / 1024 ) . " Kb</em>";
          move_uploaded_file( $_FILES[file][tmp_name], "upload/books.xml" );
          echo "Stored in: <em>upload/books.xml</em>";
          chmod( "upload/books.xml", 0755 );
        else {
          echo "Error: " . $_FILES[file][error];
          print_r( $_FILES[file] );
      else {
        echo "Invalid file";
        print_r( $_FILES[file] );
    elseif ( $_POST['act'] == "Check the upload" ) {
      header( "Location: upload/books.xml" );

    elseif ( $_POST['act'] == "Help" ) {
      header( "Content-type: text/html" );
      system( "cat help.html" );  

The following features will be considered when grading: