Question: Perform the numbered tasks in the code provided in order to build and test a database-backed shopping cart application. Extra credit: Provide a link on

Perform the numbered tasks in the code provided in order to build and test a database-backed shopping cart application.

Extra credit: Provide a link on the login page that takes the user to a registration page where the credentials are securely stored in a new database table. Normal authentication (i.e., user login) should use this new table to validate the user's login credentials.

authenticate.php

// 2. authtenticate the user's credentials: valid users provide the password: "foo" $valid = true; // replace this hard-coded value with true or false based on rule above

if ($valid) { // 3. put the authenticated user's name into the SESSION for later use header("Location: cart.php"); } else { header("Location: index.html"); } ?>

cart.php

// get the cart out of the SESSION (if the cart is not in the SESSION, create it) if (isset($_SESSION['cart'])) { $cart = $_SESSION['cart']; } else { $cart = array(); } // add the new item to the cart $cart[] = $_REQUEST['item'];

// put the cart back into the session (adding a new item may have resulted in a new object in memory) $_SESSION['cart'] = $cart; ?>

Cart Contents:


"; // 6. loop through the cart array and show each entry as a list item using the HTML li tag echo ""; ?>

Add to your cart:

officemin database

drop database officemin; create database officemin;

use officemin; create table items (id int primary key auto_increment, brand varchar(255), product varchar(255), price decimal(5, 2) );

insert into items (brand, product, price) values ("Folgers", "Coffee", 7.99); insert into items (brand, product, price) values ("Dunder Mifflin", "Copy Paper", 53.99); insert into items (brand, product, price) values ("Philipino", "Manila Folders", 6.99); insert into items (brand, product, price) values ("HP", "Ink Cartridge", 36.99); insert into items (brand, product, price) values ("Sparkle", "Paper Towels", 8.99); insert into items (brand, product, price) values ("Gordon", "Flash Drive", 9.59);

index.html

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!