project in files? additional instructions:? ? How to run the Online Shopping Store Application 1. Download the zip file 2. Extract the file and copy
project in files
additional instructions:
How to run the Online Shopping Store Application
1. Download the zip file
2. Extract the file and copy OnlineStore folder
3. Paste inside root directory(xampp/htdocs)
4. Open phpMyAdmin
5. Create a database with name storedb
6. Import storedb.sql file (given inside the zip package in SQL folder)
Configuration and Sample code for Currency Formatting:
- in php.ini, uncomment extension=intl (to uncomment, remove ';' from its start), then save
- stop then start apache
Sample code:
<?php
$fmt = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
//to remove decimal points:
//$fmt->setAttribute(NumberFormatter::FRACTION_DIGITS, 0);
echo $fmt->formatCurrency(100, 'USD'); // <--Put the value and currency here
?>
ITIS345/ITIS477 Group Project Second Semester 2021-2022
University of Bahrain
College of Information Technology
Department of Information Systems
ITIS345/ITIS477 Web Design and Development II
Course Project Developing a Complete PHP Web Application
Online Shopping Store
Project Deadline: 12 May 2022
Group number Student ID Student Name
Mark Distribution :
Assessment Maximum Mark scored mark
Report
Total: 12 %
Report structure, layout, language, and format.
2 %
Web site users and user Session 2 % Security (MD5 and SQL Injection Protection)
2 %
Country Currency and Exchange Rates (Web Service)
2 %
Country Preference in the Cookies
2 %
Appendix: source code 2 %
Presentation 6 %
Peer Review 2 %
Total 20 %
Description
The decision of the web development path has become a challenge and requires adopting the best
practices and studying available roadmaps to achieve the expected outcomes. “PHP (recursive
acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting
language that is especially suited for web development and can be embedded into HTML…PHP is
mainly focused on server-side scripting” (PHP Introduction, n.d.)
It is widely used, flexible, and provides multiple integration opportunities with different platforms and
technologies. Developing a complete web application including front-end and back-end technologies
ITIS345/ITIS477 Group Project Second Semester 2021-2022
as one team is one of this course learning outcomes. Accordingly, solving specific business
requirements – like having an online shopping gateway for a store – through building a php-based web
application would put you on the right track towards becoming a professional developer and achieving
this course outcomes.
Task
Group members are required to configure the provided project base files and the MySQL database.
You can refer to the Readme file for some guidelines.
“Online Shopping Store” is a php web-based application that will allow website visitors to browse for
products, add products to cart, and place orders.
Your objective is to enhance the system to provide the necessary features to enable the users to use it
seamlessly and intuitively.
Business Requirements
A store needs to provide a web-based application for public so they can purchase goods and products
online without having to go to the store in-person. Users should be able to browse goods and products
and add them to their cart without having to register, but they should register before they can
proceed with placing orders. Web site users should be able to select the required country, so all prices
get displayed in the selected country currency with proper exchange rate conversion, assuming having
all prices stored in the database in US dollar. Exchange rates should be pulled from accurate sources in
the web and should reflect current rates. Users can have the ability to store their country preference.
The system should be secure, and users’ information should be securely stored in the database.
Online Shopping Store Application
– Web site users and user session:
Web site users should be able to browse products and add them to their cart, even without signing-in. But once satisfied with their items, they should be asked to sign-in or register before they can proceed with placing the order. The home page should have a “Sign-in” or “Sign-out” links so users can sign-in/sign- out if they want to. Sign-in page should allow users to sign-in, and new users should be able to Register if they are not, so they are added to the store database. Use Session State to manage individual user sessions, and make sure to kill the session upon user sign-out.
– Security:
“The MD5 Message-Digest Algorithm: "The MD5 message-digest algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input.” (PHP md5() Function, n.d.) Use md5 function – with salting – to store users’ passwords securely in the database. Moreover, the system should be protected from SQL Injection. Make sure to implement these techniques to all applicable database operations.
ITIS345/ITIS477 Group Project Second Semester 2021-2022
Country Currency and Exchange Rates:
Users should be able to select the preferred country from a drop-down list of countries. Then based on the selected country currency, the exchange rate with respect to US dollar should be taken from the result of the following web service: https://open.er-api.com/v6/latest/USD The above web service is an open API and can be used without an API key. Once you get the rate, replace all prices on the page with the new values calculated based on the exchange rate. Use PHP NumberFormatter class to format the prices with the selected currency using formatCurrency method. You can refer to the documentation on: https://www.php.net/manual/en/numberformatter.formatcurrency.php Configuration and Sample code is also available in the Readme file.
– Country Preference in the Cookies: Use cookies to store user preference of the country for currency calculations. Then the system should retrieve this information to change the prices in the web site whenever the user visits the site again.
Groupwork Progress and Distribution
• Each group should have 4 members that work together. Members should exchange communication
details.
• Group members should work together and set a semi-weekly (twice a week) meeting to discuss their
work and assignments. More time will be required to assemble and finalize the report.
• A shared folder between the members should be created for project-related work.
• While the work will be distributed amongst the group members, all should contribute to every
aspect of the project. “Slacking” is not tolerable.
Report
The report should be original, well written, and neatly formatted. It should cite various resources in addition to the official. The report should use paraphrasing with proper referencing using a common referencing standard such as ACM, IEEE, or APA. The report expected length is 2500 words excluding references and source code. The report content may vary. For a general guide have a look at the University of Leicester Writing Report Study Guide1.
1 https://libguides.reading.ac.uk/reports/structuring
ITIS345/ITIS477 Group Project Second Semester 2021-2022
The report should include:
• Cover page stating the members, course, and section, topic as well as the group number.
• The report must be evenly formatted and include page numbers.
• Any figures, tables, or charts must be numbered.
• References most be formatted properly. Report content should cover the following sections with explanation and implementation method, you need to illustrate important snippets of your “php source code” for each section clearly:
• Web site users and user Session
• Security (MD5 and SQL Injection Protection)
• Country Currency and Exchange Rates (Web Service)
• Country Preference in the Cookies
• Appendix: Source Code
All reports will be subjected to plagiarism detection tools to ensure the authenticity of the content.
Presentation
In addition to the report, a max of 15-minute presentation summary should be recorded and submitted with the project. It should highlight the important points and findings. The presentation aids can be slides, code snippets, and diagrams only (no videos from other sources). You must record a walkthrough of the system, each group member must present, and the full presentation should be edited and submitted as one video. Some of the video presentation tools:
• Open Broadcaster Software (Freeware) https://obsproject.com/ OR
• Debut Video Capture and Screen Recorder Software (Free Trial / full version is around 13 BD): https://www.nchsoftware.com/capture/index.html
Deadlines & Deliverables
• Report
o Upload soft copy (Word and Adobe PDF) (Upload link will be provided)
• Recorded Presentation (including System Walkthrough):
o Upload video file (Instructions will be provided)
• Peer Reviews:
o Each student should review and rate two of colleagues’ presentations via an online form.
(Instructions will be provided)
ITIS345/ITIS477 Group Project Second Semester 2021-2022
Assessment Criteria and Marking Scheme
Marks Category Marked Items Description
12 Report • Report content and structure: o Web site users and user Session o Security (MD5 and SQL Injection
Protection) o Country Currency and Exchange Rates
(Web Services) o Country Preference in the Cookies o Appendix: source code
• Report layout, language, and format
6 Presentation Video (including System Walkthrough)
• Presentation content
• Presentation flow and language
• System Walkthrough
2 Peer Ratings (each student)
• 2 peer ratings
Bibliography
PHP Introduction. (n.d.). Retrieved from php: https://www.php.net/ PHP md5() Function. (n.d.). Retrieved from w3schools:
https://www.w3schools.com/php/func_string_md5.asp
,
Project/OnlineStore/cart.php
<?php // If the user clicked the add to cart button on the product page we can check for the form data if (isset($_POST['product_id'], $_POST['quantity']) && is_numeric($_POST['product_id']) && is_numeric($_POST['quantity'])) { // Set the post variables so we easily identify them, also make sure they are integer $product_id = (int)$_POST['product_id']; $quantity = (int)$_POST['quantity']; // Prepare the SQL statement, we basically are checking if the product exists in our databaser $stmt = $pdo->prepare('SELECT * FROM products WHERE id = ?'); $stmt->execute([$_POST['product_id']]); // Fetch the product from the database and return the result as an Array $product = $stmt->fetch(PDO::FETCH_ASSOC); // Check if the product exists (array is not empty) if ($product && $quantity > 0) { // Product exists in database, now we can create/update the session variable for the cart if (isset($_SESSION['cart']) && is_array($_SESSION['cart'])) { if (array_key_exists($product_id, $_SESSION['cart'])) { // Product exists in cart so just update the quanity $_SESSION['cart'][$product_id] += $quantity; } else { // Product is not in cart so add it $_SESSION['cart'][$product_id] = $quantity; } } else { // There are no products in cart, this will add the first product to cart $_SESSION['cart'] = array($product_id => $quantity); } } // Prevent form resubmission… header('location: index.php?page=cart'); exit; } // Remove product from cart, check for the URL param "remove", this is the product id, make sure it's a number and check if it's in the cart if (isset($_GET['remove']) && is_numeric($_GET['remove']) && isset($_SESSION['cart']) && isset($_SESSION['cart'][$_GET['remove']])) { // Remove the product from the shopping cart unset($_SESSION['cart'][$_GET['remove']]); } // Update product quantities in cart if the user clicks the "Update" button on the shopping cart page if (isset($_POST['update']) && isset($_SESSION['cart'])) { // Loop through the post data so we can update the quantities for every product in cart foreach ($_POST as $k => $v) { if (strpos($k, 'quantity') !== false && is_numeric($v)) { $id = str_replace('quantity-', '', $k); $quantity = (int)$v; // Always do checks and validation if (is_numeric($id) && isset($_SESSION['cart'][$id]) && $quantity > 0) { // Update new quantity $_SESSION['cart'][$id] = $quantity; } } } // Prevent form resubmission… header('location: index.php?page=cart'); exit; } // Send the user to the place order page if they click the Place Order button, also the cart should not be empty if (isset($_POST['placeorder']) && isset($_SESSION['cart']) && !empty($_SESSION['cart'])) { header('Location: index.php?page=placeorder'); exit; } // Check the session variable for products in cart $products_in_cart = isset($_SESSION['cart']) ? $_SESSION['cart'] : array(); $products = array(); $subtotal = 0.00; // If there are products in cart if ($products_in_cart) { // There are products in the cart so we need to select those products from the database // Products in cart array to question mark string array, we need the SQL statement to include IN (?,?,?,…etc) $array_to_question_marks = implode(',', array_fill(0, count($products_in_cart), '?')); $stmt = $pdo->prepare('SELECT * FROM products WHERE id IN (' . $array_to_question_marks . ')'); // We only need the array keys, not the values, the keys are the id's of the products $stmt->execute(array_keys($products_in_cart)); // Fetch the products from the database and return the result as an Array $products = $stmt->fetchAll(PDO::FETCH_ASSOC); // Calculate the subtotal foreach ($products as $product) { $subtotal += (float)$product['price'] * (int)$products_in_cart[$product['id']]; } } ?> <?=template_header('Cart')?> <div class="cart content-wrapper"> <h1>Shopping Cart</h1> <form action="index.php?page=cart" method="post"> <table> <thead> <tr> <td colspan="2">Product</td> <td>Price</td> <td>Quantity</td> <td>Total</td> </tr> </thead> <tbody> <?php if (empty($products)): ?> <tr> <td colspan="5" style="text-align:center;">You have no products added in your Shopping Cart</td> </tr> <?php else: ?> <?php foreach ($products as $product): ?> <tr> <td class="img"> <a href="index.php?page=product&id=<?=$product['id']?>"> <img src="imgs/<?=$product['img']?>" width="50" height="50" alt="<?=$product['name']?>"> </a> </td> <td> <a href="index.php?page=product&id=<?=$product['id']?>"><?=$product['name']?></a> <br> <a href="index.php?page=cart&remove=<?=$product['id']?>" class="remove">Remove</a> </td> <td class="price">$<?=$product['price']?></td> <td class="quantity"> <input type="number" name="quantity-<?=$product['id']?>" value="<?=$products_in_cart[$product['id']]?>" min="1" max="<?=$product['quantity']?>" placeholder="Quantity" required> </td> <td class="price">$<?=$product['price'] * $products_in_cart[$product['id']]?></td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> <div class="subtotal"> <span class="text">Subtotal</span> <span class="price">$<?=$subtotal?></span> </div> <div class="buttons"> <input type="submit" value="Update" name="update"> <input type="submit" value="Place Order" name="placeorder"> </div> </form> </div> <?=template_footer()?>
Project/OnlineStore/currency_sample_code.php
<?php //in php.ini, uncomment extension=intl (remove ';' from its start) //stop then start apache $fmt = new NumberFormatter('en_US', NumberFormatter::CURRENCY); //to remove decimal points: //$fmt->setAttribute(NumberFormatter::FRACTION_DIGITS, 0); echo $fmt->formatCurrency(100, 'GBP'); ?>
Project/OnlineStore/functions.php
<?php function pdo_connect_mysql() { // Update the details below with your MySQL details $DATABASE_HOST = 'localhost'; $DATABASE_USER = 'root'; $DATABASE_PASS = ''; $DATABASE_NAME = 'storedb'; try { return new PDO('mysql:host=' . $DATABASE_HOST . ';dbname=' . $DATABASE_NAME . ';charset=utf8', $DATABASE_USER, $DATABASE_PASS); } catch (PDOException $exception) { // If there is an error with the connection, stop the script and display the error. exit('Failed to connect to database!'); } } // Template header, feel free to customize this function template_header($title) { // Get the amount of items in the shopping cart, this will be displayed in the header. $num_items_in_cart = isset($_SESSION['cart']) ? count($_SESSION['cart']) : 0; $countries = ['BHD'=>'Bahrain', 'BRL'=>'Brazil', 'CAD'=>'Canada', 'CNY'=>'China', 'EUR'=>'Euro', 'INR'=>'India', 'JPY'=>'Japan', 'GBP'=>'United Kingdom', 'USD'=>'United States']; $options = ''; foreach($countries as $currency=>$country) { //Check the Cookie here to make the default country, keep US as default if no cookie if($currency=='USD') $options = $options.'<option value='.$currency.' selected>'.$country.'</option>'; else $options = $options.'<option value='.$currency.'>'.$country.'</option>'; } echo <<<EOT <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>$title</title> <link href="style.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css"> </head> <body> <header> <div class="content-wrapper"> <h1>Online Shopping Store</h1> <nav> <a href="index.php">Home</a> <a href="index.php?page=products">Products</a> <select name="countries" id="countries"> $options </select> </nav> <div class="link-icons"> <a href="index.php?page=cart"> <i class="fas fa-shopping-cart"></i> <span>$num_items_in_cart</span> </a> </div> </div> </header> <main> EOT; } // Template footer function template_footer() { $year = date('Y'); echo <<<EOT </main> <footer> <div class="content-wrapper"> <p>© $year, Online Shopping Store</p> </div> </footer> <script src="script.js"></script> </body> </html> EOT; } ?>
Project/OnlineStore/home.php
<?php // Get the 4 most recently added products $stmt = $pdo->prepare('SELECT * FROM products ORDER BY date_added DESC LIMIT 4'); $stmt->execute(); $recently_added_products = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> <?=template_header('Home')?> <div class="featured"> <h2>Gadgets</h2> <p>Essential gadgets for everyday use</p> </div> <div class="recentlyadded content-wrapper"> <h2>Recently Added Products</h2> <div class="products"> <?php foreach ($recently_added_products as $product): ?> <a href="index.php?page=product&id=<?=$product['id']?>" class="product"> <img src="imgs/<?=$product['img']?>" width="200" height="200" alt="<?=$product['name']?>"> <span class="name"><?=$product['name']?></span> <span class="price"> $<?=$product['price']?> <?php if ($product['rrp'] > 0): ?> <span class="rrp">$<?=$product['rrp']?></span> <?php endif; ?> </span> </a> <?php endforeach; ?> </div> </div> <?=template_footer()?>
Project/OnlineStore/imgs/camera.jpg
Project/OnlineStore/imgs/featured-image.jpg
Project/OnlineStore/imgs/headphones.jpg
Project/OnlineStore/imgs/wallet.jpg
Project/OnlineStore/imgs/watch.jpg
Project/OnlineStore/index.php
<?php session_start(); // Include functions and connect to the database using PDO MySQL include 'functions.php'; $pdo = pdo_connect_mysql(); // Page is set to home (home.php) by default, so when the visitor visits that will be the page they see. $page = isset($_GET['page']) && file_exists($_GET['page'] . '.php') ? $_GET['page'] : 'home'; // Include and show the requested page include $page . '.php'; ?>
Project/OnlineStore/placeorder.php
<?=template_header('Place Order')?> <div class="placeorder content-wrapper"> <h1>Your Order Has Been Placed</h1> <p>Thank you for ordering with us, we'll contact you by email with your order details.</p> </div> <?=template_footer()?>
Project/OnlineStore/product.php
<?php // Check to make sure the id parameter is specified in the URL if (isset($_GET['id'])) { // Prepare statement and execute, prevents SQL injection $stmt = $pdo->prepare('SELECT * FROM products WHERE id = ?'); $stmt->execute([$_GET['id']]); // Fetch the product from the database and return the result as an Array $product = $stmt->fetch(PDO::FETCH_ASSOC); // Check if the product exists (array is not empty) if (!$product) { // Simple error to display if the id for the product doesn't exists (array is empty) exit('Product does not exist!'); } } else { // Simple error to display if the id wasn't specified exit('Product does not exist!'); } ?> <?=template_header('Product')?> <div class="product content-wrapper"> <img src="imgs/<?=$product['img']?>" width="500" height="500" alt="<?=$product['name']?>"> <div> <h1 class="name"><?=$product['name']?></h1> <span class="price"> $<?=$product['price']?> <?php if ($product['rrp'] > 0): ?> <span class="rrp">$<?=$product['rrp']?></span> <?php endif; ?> </span> <form action="index.php?page=cart" method="post"> <input type="number" name="quantity" value="1" min="1" max="<?=$product['quantity']?>" placeholder="Quantity" required> <input type="hidden" name="product_id" value="<?=$product['id']?>"> <input type="submit" value="Add To Cart"> </form> <div class="description"> <?=$product['desc']?> </div> </div> </div> <?=template_footer()?>
Project/OnlineStore/products.php
<?php // The amounts of products to show on each page $num_products_on_each_page = 4; // The current page, in the URL this will appear as index.php?page=products&p=1, index.php?page=products&p=2, etc… $current_page = isset($_GET['p']) && is_numeric($_GET['p']) ? (int)$_GET['p'] : 1; // Select products ordered by the date added $stmt = $pdo->prepare('SELECT * FROM products ORDER BY date_added DESC LIMIT ?,?'); // bindValue will allow us to use integer in the SQL statement, we need to use for LIMIT $stmt->bindValue(1, ($current_page – 1) * $num_products_on_each_page, PDO::PARAM_INT); $stmt->bindValue(2, $num_products_on_each_page, PDO::PARAM_INT); $stmt->execute(); // Fetch the products from the database and return the result as an Array $products = $stmt->fetchAll(PDO::FETCH_ASSOC); // Get the total number of products $total_products = $pdo->query('SELECT * FROM products')->rowCount(); ?> <?=template_header('Products')?> <div class="products content-wrapper"> <h1>Products</h1> <p><?=$total_products?> Products</p> <div class="products-wrapper"> <?php foreach ($products as $product): ?> <a href="index.php?page=product&id=<?=$product['id']?>" class="product"> <img src="imgs/<?=$product['img']?>" width="200" height="200" alt="<?=$product['name']?>"> <span class="name"><?=$product['name']?></span> <span class="price"> $<?=$product['price']?> <?php if ($product['rrp'] > 0): ?> <span class="rrp">$<?=$product['rrp']?></span> <?php endif; ?> </span> </a> <?php endforeach; ?> </div> <div class="buttons"> <?php if ($current_page > 1): ?> <a href="index.php?page=products&p=<?=$current_page-1?>">Prev</a> <?php endif; ?> <?php if ($total_products > ($current_page * $num_products_on_each_page) – $num_products_on_each_page + count($products)): ?> <a href="index.php?page=products&p=<?=$current_page+1?>">Next</a> <?php endif; ?> </div> </div> <?=template_footer()?>
Project/OnlineStore/style.css
* { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "segoe ui", roboto, oxygen, ubuntu, cantarell, "fira sans", "droid sans", "helvetica neue", Arial, sans-serif; font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } html { height: 100%; } body { position: relative; min-height: 100%; color: #555555; background-color: #FFFFFF; margin: 0; padding-bottom: 100px; /* Same height as footer */ } h1, h2, h3, h4, h5 { color: #394352; } .content-wrapper { width: 1050px; margin: 0 auto; } header { border-bottom: 1px solid #EEEEEE; } header .con
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
All Rights Reserved Terms and Conditions
College pals.com Privacy Policy 2010-2018