PHP代写 | Web Programming Assignment3

本次PHP代写的主要内容为期末project,该project需要学生完成一个中大型的PHP网站开发,里面有产品展示、购物车、结算、结算信息查看等功能。

Requirements

1.  Website and Page Structure

 

Content on all pages / facilities above must be neatly laid out, attention to alignment and proximity must be observed.

All prices must be numeric and displayed with a “$” in front and to 2 decimal places at all times.

All your CSS and JS must be in external files (ie do not use inline and embedded versions unless there is a very good reason for doing so).

All pages must be PHP and must have access to the session object, ie use session_start() near the top of every page. Framework code, ie code common to all pages, must be moved out to functions or some other method explicitly approved ahead of time by the instructor.

A debug module must also be included. Instructions are provided in the tute lab sheets and will work for offline and online hosting options.

Implementation of all the above tasks must be complete in order to earn marks. The client would like to have three more pages (or facilities):

1.  Cart Page / Facility

When a customer has finished making selections from the product page / facilities, they can progress to the cart page or facility and see all of their purchases, item subtotals and order total.

2.  Checkout Page / Facility

When a customer has finished reviewing their purchases in the cart page / facility, they can progress to the checkout page or facility, enter their details and complete their purchase.

3. Receipt Page

When a customer has finished entering their details in the checkout page / facility, they can progress to the receipt page. This page must display their complete order in a printable format. What this means is that the page should be styled with a different stylesheet and must look like an A4 letterhead page with business / organisation branding when viewing in “print preview” mode.

Your client no longer needs a single product or service page. This functionality will be built into the existing products or services page.

You should also create a file called tools.php that contains functions for each page to use. Some starting functions (blue text) have been provided on the last page of this assignment document with examples of calling code (red text) to use in you php files.

 

2.  Products (Services) Page Upgrades

2.1  Spreadsheet Read

The client would like to supply you with a spreadsheet of product / service information. The spreadsheet must be read and the product information in the site must come from a tab delimited spreadsheet called products.txt or services.txt. Make sure that your supplied spreadsheet has a row of headings and multiple rows of data in the following order:

ID OID Title Description Option Price
T123 SML Mens T-Shirt This is a small men’s Tshirt … small 25.5
T123 LRG Mens T-Shirt This is a small men’s Tshirt … large 25.5

A link to your spreadsheet must be placed in the footer.

 

2.2  Combined Product / Products Page

All features present in the single and combined product / service pages must be combined into a single products or services page.

  • When no valid product or service id is present in the GET header, all products or services are

displayed with no purchasing controls.

eg products.php and products.php?id=FAKE_ID

  • When a valid product or service id is present in the GET header, a single product or service is displayed with a form, purchasing controls (quantity field; -, + and add to cart buttons; options dropdown or radio buttons) and a price subtotal in a span element for that item.

eg products.php?id=LEGIT_ID

if (isset($_GET['id']) && this_id_actually_exists($_GET['id'])) {

// show a single product or service matching id with a purchasing form

} else {

// show all products or services without purchasing form

}

2.3 a Combined Product / Products Page Update

To minimise word confusion, if your website has services, substitute the word “product” with “service” in the language and filenames below.

Where language differs significantly from the original text, it is displayed in bold text.

Original (harder) option New (easier) option Modal box (advanced) option
All products (plural) summaries are displayed in products.php when no valid id is present in the GET header. No form controls are displayed, only links to individual products, eg products.php?id=LEGIT_ID, where LEGIT_ID is a valid product id in your assignment. Single product page redirects user to products page where all products (plural) summaries are displayed in products.php when no valid id is present in the GET header. No form controls are displayed, only links to individual products, eg product.php?id=LEGIT_ID, where LEGIT_ID is a valid product id in your assignment. No modal windows are displayed, all products (plural) summaries are displayed in products.php or services.php when no valid id is present in GET header. No form controls are displayed other than those necessary to open individual product modal boxes.
Single product in products.php is displayed when a valid id is present in the GET header. Single product in product.php is displayed when a valid id is present in the GET header. Single product is displayed in a modal box when a valid id is present in the GET header.
Purchasing controls are only shown on single product page, eg products.php?id=LEGIT_ID, where LEGIT_ID is a valid product id in your assignment. Purchasing controls are only shown on single product page, eg product.php?id=LEGIT_ID, where LEGIT_ID is a valid product id in your assignment. Purchasing controls are only shown on a single product modal box window eg where id=LEGIT_ID is a valid product id in your assignment.

 

2.4   Javascript Functionality

Use javascript to calculate and display a subtotal price for the item as the user makes selections (ie as the user clicks the buttons or enters a quantity directly). Advanced users: you may wish to factor in different prices for different options.

2.5   PHP Functionality

When the customer clicks the add to cart button, the product or service ID, option id and quantity must be submitted to the server via the POST method and added to a shopping cart in the SESSION. The user must then arrive on the cart page, for example:

if (isset($_POST['add'], $_POST['id'], $_POST['qty'], $_POST['oid'])) {

// server side code is required here to validate and check if

//  - qty is a positive integer (ie 1 or more)

//  - product/service and option ids are valid

$_SESSION['cart'][$id]['oid'] = $oid;

$_SESSION['cart'][$id]['qty'] = $qty;

// redirection BEFORE any HTML is outputted header("Location: cart.php");

}

This can either be in a separate processing script or near the top of cart.php, in which case the header redirect is not needed.

 

3.  Cart Page / Facility

The cart page or facility must display all products, options and quantities ordered in an organised fashion. A button or link should be present to advance the user to the checkout page / facility.

Another button or link should be present to cancel the entire order, after which the user should be redirected to the products page, for example:

if (isset($_POST['cancel'])) { unset($_SESSION['cart']); header("Location: products.php");

}

This can either be in a separate processing script or near the top of products.php, in which case the header redirect is not needed.

4.  Checkout Page / Facility

The checkout page or facility must collect the following information which must be validated server side and conform to these criteria:

 

Name Type Description Validation Required
Name text All names of customer ie first and last names. Alphabetic characters, plus some punctuation chars: space, full stop, comma, single quote and hyphen. Yes
Email email email address A filter_var() function check the using

FILTER_VAR_EMAIL flag is fine

Yes
Address text area Multiple lines of text. Numbers and alphabetic characters, plus some punctuation chars: space, full stop, comma, single quote, hyphen, forward slash and line feed char. Yes
Mobile Phone text Australian mobile. Must start with +614, (04) or 04; then any grouping of 8 more digits and single spaces is permitted. Yes
Credit Card text Credit card number. Any grouping of 12 – 19 numbers and single spaces are permitted. Yes
Expiry Date date or selects The expiry date of the credit card. Cannot expire within one month of purchase, for example, if making purchase in December 2017, expiry date must be February 2018 or later. Yes

 

As an added feature, when a valid visa number is entered, a small visa logo should appear next to the credit card field and disappear / not appear if not a VISA number. This should be done using a javascript event handler function and be triggered by the credit card’s oninput event.

5.  Receipt Page and Orders Spreadsheet

 

Once the client’s details are validated, orders must be appended to your existing comma separated spreadsheet called orders.txt according to the following format:

Servers normally allow PHP scripts to create files, however due to permissions issues on Coreteaching machines, put the heading row in manually and give the spreadsheet chmod 606 permission.

A link to your orders.txt spreadsheet must be placed in the footer.

Unit prices and subtotals should be calculated server side based on quantities provided to the server. Do not trust the client to tell you what the unit price and the subtotal price is.

Also, make sure that no orders with invalid product / service and option ids are stored in the spreadsheet. For security reasons, the credit card number and expiry date should not be stored as part of this assignment.