Кирпичик

A Simple E-Shop Application Using PHP and MySQL

SPECIFICATION:

Write a simple E-shop application using PHP and MySQL*. This may be a bookshop, music shop, clothes store, or anything else you wish. There should be a “user” interface to allow customers to select and purchase items (don’t worry about the payment side of things). Ideally there should also be a password-protected “owner” interface, to allow the E-shop operator to view/edit stock and pending orders.

The exercise is deliberately “hard” given the short deadline, and I do not expect everyone necessarily to complete it to perfection. This will be taken into account in the marking.

MARKING SCHEME:

[A 5%] Ability to write working HTML code (i.e. code that creates successful markup on a browser window).**

[B 5%] Ability to post an HTML web-page on a server such that it is visible on the World Wide Web. ***

[C 10%] Ability to make an HTML form communicate with a PHP script.**

[D 10%] Ability to make a PHP script interact with a MySQL database.**

[E 40%] Functionality (the extent to which the software’s operation complies with – or exceeds- the original specification).

[F 10%] User friendliness (the extent to which the browser displays are clear and self-explanatory).

[G 10%] Presentation. (This could include appropriate use of images, colour, text fonts, style-sheets and dynamic HTML functions.)

[H 10%] Clarity and readability of coding and related documentation (e.g. use of comments, appropriate indentation etc.)

NOTES:

*If you wish to use different web-based technologies (e.g. ASP, JSP, Pearl) please do so. However, please do NOT use high-level software packages which require no programming skills (e.g. “wysiwyg” HTML editors), as these rather defeat the purpose of taking this module.

** In categories A to D, the marks are awarded in a “binary” manner (i.e. the student receives either the entire weighting mark or else zero). Thus 30% can be obtained simply by demonstrating a basic knowledge of HTML, PHP and MySQL. The remaining categories are marked in a “continuous” fashion (i.e. any number of marks between zero and the weighting value can be awarded).

*** In the event of server failure (or other irresolvable technical difficulties) Category B will be removed and the weightings of the other categories scaled accordingly.

SOLUTION:

My electronic shop application is for the sale of books and other assorted item sold by the Wandle Industrial Museum.

This development is a logical extension to an existing static website. The data and basic layout of my application are derived from this pre-existing work.

THE MAIN INTERFACE:

the initial screen, not including the original frames used in the Museum website. Most of the content in the top and bottom frames is non functional and is included for completeness, this also helps demonstrate the dynamic HTML that provided secondary navigation structures.

This screen shown the main body of the shop information and the “shopping basket” functions at the button. This page provides access to:

1) A complete list of the online “catalogue”;

2) A subset of the catalogue listed by product category;

3) A subset of the catalogue based on user defined search terms;

4) More detailed information about an item;

5) Ability to add items to a session based “shopping basket”;

6) Ability you registered users to write book reviews;

If a user is new to the application, he/she is shown the message “Welcome. Already a customer? Click here to sign in”, otherwise they see their user name and a button to the right named “My account” which allows them to edit their information . This information is stored in a client side cookie that is retained for 30 minutes.

ABOUT THE SUMMARY DISPLAY:

The summary of items shows the item code, title, price, description and stock level of all items. The display also includes two additional other possibilities, 1 items that are out of stock are show in red text. 2 items that are not sold through the online shop are “grayed-out” in both these cases the “buy” button is removed from all displays for a given item.

THE BASKET:

The Basket Initially there is not shopping basket until the user adds an item, until such time clicking on the “view basket button shows a default screen.

When an item is added, its quantity is set to one by default, this can either be increased by adding the same item to the basket again or by clicking in the increment button on the basket display screen shown here. Once a basket is created and the user enters the system the following options are available under the product description:

1) Clear cart;

2) Continue shopping;

3) Checkout;

If the item is de-incremented to zero then it is removed from the basket.

The basket is based on PHP sessions and unlike the users identity, which is reined for 30 minutes, will not persist after the instance on the browser is closed.

If the user is unknown to the application when he/she attempts to complete the transaction, they will be asked to sign in, if the user has an account he/she can login and continue with the transaction.

If the user has not got an account he/she must register before being able to finish buying anything.

ADDING ITEMS TO THE SHOPPING BASKET:

Items can be added to shopping basket either from any summary listing, or an item description page.

A summary page displays basic item information in a tabular format whithout images, such as the one shown right by clicking on the “buy” button at the left on the item line.

This can also be done from the item detail page, which is displayed by clicking the items code shown on the left of the summary display.

Each item detail page also includes a “buy” button as well as the other shopping basket tools” These are on the summary page but at the bottom so require scrolling

The database supports two forms of items, “books”, as shown above, which include information specific to reading materials, and “goods” which only include basic item information, item code, title and price.

Where images ae not available a replacement is automatically instituted until the administrator specifies a real image.

ABOUT THE USER:

If the user is unknown to the application when he/she attempts to complete the transaction, they will be asked to sign in, if the user has an account he/she can login and continue with the transaction

If the user has not got an account he/she must register before being able to finish buying anything. Here we see the effect of an invalid attempt to register a new account. The user is given a text description of the error and the suspect entities are highlight in sequence until all anomalies have been resolved.

After the user has registered he/she is asked to print the form for his/her reference. Then is logged in and can bypass authentication when buying.

The application has been hard coded with one administrative account, the username is “system” and the password is “god” Note there is currently no way to change this.

The administration display allows the users to:

1) define new item types;

2) Edit and delete users;

3) Add, edit and delete categories;

This screen allows the user to either edit an existing data item in a given category identified by its product code or create a new product date item. The application includes a specific set of validation criteria as shown in the next image. Items are listed alpha numerically, left to right.

Here we see the result of a failed data entry operation denoted by crosses to denote invalid or missing entries for given fields, likewise a tick indicates the field is valid.

It is possible to have a blank correct entry – eg, if there are no images these boxes should be left clear.

The question mark is to double check the intention to leave blank in certain cases

This screen shows that theadministrator has chosen to delete a user’s account from the database – the edit and delete functions use the same display except that the edit function does not show the delete warning

The interface The image shows the initial (welcome) screen, not including the frames used in the Museum website.

This screen shown the main body of the shop information and the “shopping basket” functions at top and the button. This page provides access to:

1) A complete list of the online “catalogue”;

2) A subset of the catalogue listed by product category;

3) Ability to order the catalogue listed by product code, price or title, in acceding order;

4) A subset of the catalogue based on user defined search terms;

5) More detailed information about an item;

6) Ability to add items to a session based “shopping basket”;

If a user is new to the application, he/she is shown the message “Welcome. Already a customer? Click here to sign in”, otherwise they see their user name and a button to the right named “My account” which allows them to edit their information. This information is stored in a client side cookie that is retained for 30 minutes.

The administration display allows the users to:

1) Define new item types;

2) Edit and delete users;

3) Add, edit and delete categories;

4) Add, edit, move and delete products;

5) Edit and add help information;

6) Create and restore dumps of tables;

DATABASE DICTIONARY:

A data dictionary defines the common terms, codes, and conventions used. Listed below are the database lookup tables required for the shop database application.

Table: bookinfo:

Comments: Book specific metadata. Field Type Null Default
code varchar(5) No No
author varchar(50) No Unknown
publisher varchar(100) No Unknown
isbn varchar(15) No None
illustrations varchar(15) Yes Yes - gray
date date Yes NULL
dimensions varchar(100) No Unknown
summary text No
type varchar(16) No

Table: categories:
Comments: Product metadata Field Type Null Default
id int(3) No
name varchar(50) No
etype int(1) No 2
Keywords varchar(100) No

Table: customers:
Comments: Customer billing information. Field Type Null Default
uname varchar(15) No
first_name varchar(25) No
last_name varchar(25) No
phone varchar(20) No
email varchar(50) No
zip varchar(10) No
city varchar(50) No
country_code int(2) No 0
bill_address varchar(90) No
changed timestamp(14) Yes NULL

Table: orderdata:
Comments: Customer order information Field Type Null Default
ordernumber int(5) No 0
itemcode varchar(5) title varchar(100) No
quantity int(3) No 0
total float No 0
status int(11) No 0
stamp timestamp(14) Yes NULL

Table: orders:
Comments: customer order refferance data. Field Type Null Default
uname varchar(15) No 0
ordernumber int(5) No
status int(1) No 0
date date Yes NULL

Table: reviews:
Comments: user book reviews and rations. Field Type Null Default
uname varchar(15) No 0
type int(1) No
rating int(1) No 0
stamp timestamp(14) Yes NULL
review text No

Table: products:
Table comments: Primary product data. Field Type Null Default
code varchar(5) No
category_id int(3) No 1
title varchar(100) No
keywords varchar(255) No
small_image varchar(15) No nopic.jpg
large_image varchar(15) No nopic.jpg
description text No
price decimal(5,2) No 00.00
date_modified date No 0000-00-00
status int(1) No 1
Table: purchase:
Comments: Primary product data. Field Type Null Default
code varchar(5) No
date timestamp(14) Yes NULL
stock int(3) No> 15
cost decimal(5,2) No 00.00

Table: pwl:
Comments: User password/access information. Field Type Null Default
uname varchar(15) No
upass varchar(100) No 5d2e19393cc5ef67
created timestamp(14) Yes NULL

Table: syshelpindex:
Comments: System help subject index.Field Type Null Default
cat int(2) No 0
subject varchar(30) No

Table: syshelpinfo:
Comments: system help information.Field Type Null Default
cat int(3) No 0
title varchar(30) No
info text No
image varchar(20) No
type int(1) No 0

FILE STRUCTURE:

The electronic shop application is for the sale of books and other assorted item sold by the Wandle Industrial Museum. This development is a logical extension to an existing static website.

The application’s files are stored in 9 subdirectories. These are as follows:

../htdocs/order.htg/ This is the root directory of the web application, it contains all resources related to the website. All generic files and ancillary elements are stored at this level. (3.74mb 263 files)

../htdocs/order.htg/common.htg/ This directory contains all common utility scripts and other resources that the web application depends upon.(185kb 50 files)

../htdocs/order.htg/data_backup/ This directory is used to store SQL dump files..(242kb 3 files)

../htdocs/order.htg/help/ This directory is used to store graphics for help desk database. (336kb 26 files)

../htdocs/order.htg/images.htg/ This directory is used to store graphics for the shop database. (2.41mb 91 files)

../htdocs/order.htg/mysqlsnips This directory contains a set of text files related to example SQL commands.

../htdocs/order.htg/shop.htg/ This directory contains all the source files related to the public areas of the shop database utility scripts and other template resources that the web application depends upon. (85.1kb 20 files)

../htdocs/order.htg/update.htg/ This directory contains all the source files related to the administration areas of the shop database and other utility scripts. (240kb 34 files)

Exit mobile version