Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions

Question

=+j Describe the various support services delivered by IHR.

Answered: 1 week ago