Phase 4 Assignment: PHP Authentication and Delete SQL Data
Assignment Preparation
• GitHub
О For your semester website assignment, reuse the same private repository
you used in the last phase named "IT202-YourUCID-Project" and make
updates/changes to your source code
О
Do not create a new repository for this phase
Description
Building upon your website you created in Phase 1, 2 and 3 create the following SQL
table and modify/create additional PHP web pages:
1. Create a database table for storing authentication information for your store
managers.
2. Modify the header area or navigation bar in ALL web pages to display a "Login"
or "Logout" link using PHP Sessions.
a. The "Shipping" page, the "Create" page and the "Delete" buttons should
only be accessible if a user is logged in.
3. Modify your product page to include a "Delete" button for each record.
Requirements
All new new PHP pages are required to include the following HTML elements (same as
Phase 1, 2 and 3):
• Appropriate title
•
Links and navigation menu
• Images (stored in a directory named "images")
CSS margin, padding, border, width and height
Select an appropriate color scheme for your foreground and background colors
for your pages.
How to choose a color scheme?
■
Monochromatic
http://meyerweb.com/eric/tools/color-blend
Choose from a photograph or other image
http://www.colr.org
■ Begin with a favorite color Use one of the sites below to choose other colors
○
https://color.adobe.com/create/color-wheel
○ http://paletton.com
■ Select an existing color palette
https://www.w3schools.com/colors/colors palettes.asp
• https://palettes.shecodes.io/
■ Or search for "css color palette" on the internet
All text must have a specified font name and font size (do not use browser
default)
Consistent banner logo area (displayed when visiting all website pages)
• Association with external style sheet (.css file) that configures text, color and
page layout
• All content must be well organized, contain complete sentences (where
appropriate), and use correct grammar and spelling.
• All pages must contain the following HTML5 elements and they must all have a
fixed width and height
О
Header area
。 Navigation bar (containing links to both "Home" page and “Shipping" page)
O
Main/Content area
Figure elements
■https://www.w3schools.com/tags/tag_figure.asp
O
Footer area
PHP field validation (HTML5 field validation is not required in this phase). Detailed SQL Requirements
Create another database table in your NJIT SQL database server. This table will store
the login credentials for your store managers. The table name and field(s) must
specifically describe your store. Replace the "
"
with your store or shop name.
NOT NULL AUTO_INCREMENT,
VARCHAR(255) NOT NULL UNIQUE,
CREATE TABLE
_Managers (
ManagerID INT
emailAddress
password
firstName
lastName
dateCreated
VARCHAR(255) NOT NULL,
VARCHAR(60) NOT NULL,
VARCHAR(60) NOT NULL,
DATETIME
NOT NULL,
);
PRIMARY KEY ( _____ ManagerID)
Insert 3 or more records to create 3 different accounts corresponding with 3
different managers for your website. The "password" field must store the
password using the "password_hash()" function. In order to do this, create a new
PHP script to insert records similar to the following function. This script should
only be executed once (and not linked to your website), but should be part of your
assignment source code submission.
function add
}
$db = getDB();
_manager($email, $password) {
$hash=password_hash($password, PASSWORD_DEFAULT);
$query = 'INSERT INTO _____ Managers (emailAddress, password)
VALUES (:email, :password)';
$statement = $db->prepare($query);
$statement->bindValue('email', $email);
$statement->bindValue(': password', $hash);
$statement->execute();
$statement->closeCursor();
NOTE: This example function only inserts emailAddress and password, your script
should insert data in firstName, lastName and dateCreated also, as defined in the table.
Detailed PHP Requirements
1. "Login" or "Logout" link
a. The store manager should be able to "Login" and "Logout" from any web
page (Home, Shipping, etc) in order to create or delete any inventory or
create shipping labels. b. After the user logins in with the correct email and password, the "Logout"
link should be displayed. When the user logs out, the "Login" link should
be displayed (in the header area or navigation bar in all web pages).
c. In addition, the following information should also be displayed in all pages
after the manager logs in so the user is aware that he/she is logged in:
Example: "Welcome Brad Pitt (brad@pitt.com)"
i.
ii.
iii.
This information should be extracted from the "firstName",
"lastName" and "emailAddress" fields from the manager database
table.
HINT: After the user logs in successfully, store these values in the
session array so these details can be accessed from any web
page. Your session array can have several name/value pairs.
d. The following links should ONLY be visible after the user logs in
successfully, OR, hidden/unavailable when a user is not logged in:
The "Shipping" page (from the header or navigation bar)
The "Create" page (from the header or navigation bar)
The "Delete" buttons
İ.
ii.
iii.
e. If the user visits any of these pages and he/she is not logged in, there
should be an error message displayed.
2. Include a "Delete" button for each product record in the product page. When the
user selects this button it should send an HTTP POST request to a delete page
that performs the "DELETE" sql query for the selected record.
Reference
Presentation: PHP and MySQL: Chapter 04
Presentation: PHP and MySQL: Chapter 21
Document: PHP and MySQL: Chapter 21
Source Code Preparation
After you have completed and tested all source code changes and committed all
changes to GitHub, create a "tag" for this phase of your website. You may name
the tag "24SP-IT202-Phase04" or any name you like that pertains to the set of
changes for this phase.
o Managing tags in GitHub Desktop Submission Instructions
• Source Code URL
O Submit your github tag URL, for example
https://github.com/YourUCID/24SP-IT202/tree/tag-name
。 Optionally, this can be entered in the "Text Entry" or "Assignment
Comment" section in Canvas.
• Source Codes ZIP
О
о
In GitHub, select the "Download Zip" menu from the tag page. Your zip file
name should be something like "24SP-IT202-tag-name.zip". Submit thi
ZIP file containing all source code files and images used to complete
assignment.
All source code must include your name, date, course name and section,
assignment name and email.
Screen Captures ZIP
о Submit a separate ZIP file containing screenshots of your web browser
displaying the complete web page including your web browser URL
displaying your UCID.
Screenshots must contain each page based on whether the user is
logged in and logged out.
○ Photos taken of your laptop screen using your cell phone will not be
accepted.
■MacOS Instructions: Take a screenshot on your Mac
■Windows Instruction: Use Snipping Tool to capture screenshots on
Windows
• SQL Database Export
Submit one or more separate file(s) containing your database export
Instructions: Export a database with phpMyAdmin
This file should contain statements to create all database tables and all
insert statements and should have a *.sql file extension.