Website DevS22024
Website DevS22024
DUE DATE
Delays caused by computer downtime cannot be accepted as a valid reason for a late submission without
penalty. Students must plan their work to allow for both scheduled and unscheduled downtime.
Late submissions will incur a 5% penalty for each day that it is late.
Late submissions will NOT be accepted after 5 days past the due date.
Since the assignment deadline is already extended to Week 13 instead of Week 12, extension will only be
granted to special consideration requests for compelling reasons.
It is mandatory for each student to attend their allocated lab face to face in Week 13, Thursday 31st
October 9:00-11:00 am and 11:00-1:00 pm for their assignment to be marked. Please attend the lab that
you were allocated to in allocate plus. Students are free to leave once their assignment is marked. If you
cannot attend Week 13 lab for any compelling reason, please email me at r.kalaria@latrobe.edu.au before
Tuesday October 29th to make alternate arrangement.
COPYING, PLAGIARISM
This is an individual assignment. You are explicitly instructed not to work in groups.
DO NOT COPY & PASTE ANY CODE FROM WEBSITES or GENERATIVE AI.
Plagiarism is the submission of somebody else’s work in a manner that gives the impression that the work is
your own. When it is detected, penalties are strictly imposed.
SUBMISSION GUIDELINES
You are required to upload your solutions to the LMS in a zip file.
This ZIP file MUST include all the images, PHP, HTML and CSS files that your website needs to function.
When you submit your assignment, please include all the files your site needs to operate (including the
database directory).
You are NOT permitted to use any sort of automated code generation tools or programs.
Your website MUST work on the webprog.cs.latrobe.edu.au web server and display correctly in Google
Chrome.
RULES AND REQUIREMENTS
READ CAREFULLY – Marks can be reduced heavily or given 0 for failure to follow.
• The site must run correctly on webprog.cs.latrobe.edu.au server. The site must run correctly in
Google Chrome.
• All CSS styles MUST be placed into CSS file (e.g. styles.css) There must be no CSS code in your
HTML/PHP files.
• JavaScript is not allowed in this assignment, do not use any JS code. This includes but not limited to
<script> tags, and onclick attributes.
• Your code must be HTML5 compliant please use the HTML5 validator (see the end of Lab07 for
instructions),
• The website should have a consistent look and feel. All the pages should have the same layout, and
the navigation bar should always be visible to the user.
• The website should be stylized as professionally as possible. Here is the reference link to some of
the css color palettes. You can choose a color palette from above link or choose your own color
scheme as per your liking.
• Your website must be secure from SQL Injection attacks.
• You are not expected to implement any sort of password authentication system for this assignment.
• Your code must be indented and easy to read.
• Maximum upload on LMS is 100MB, so please ensure any images you use are not too large.
• Make sure you have read this document and all relevant documentation for this assignment.
TASK
You are to create a website blog based on the descriptions below, that allows users to sign up, sign in, and
create blog headings and posts for those headings.
SET-UP
"Functions.php" contains useful functions that you will need to complete the assignment. Some other files
also contain partial code provided to you.
SQL
Create a database and the three tables using the phpLiteAdmin (inside the database directory) as follows:
Name the database as ‘Blog.db’. Create three tables for this database, User, Headline, and BlogPost as
follows:
For the pages: Blog.php, Homepage.php, SignIn.php, SignUp.php, Headlines.php, and About.php
Create the divs with the appropriate ids "header", "nav", "content" and "footer"
The header should be stylized such that it stands out, contains a different background color, font color, font
and font size (not automatic), using h3 tag and contains "CSE4IFU" and the purpose of the page. For
example: “CSE4IFU-Homepage” or something similar.
The footer should be stylized such that it stands out, contains a different background color, font color and
font (not automatic), using h4 tag and contains full name as it appears in LMS, student number and
"CSE4IFU- 2024, Sem 2". For example: “Rudri Kalaria – 1234567 – CSE4IFU Sem 2, 2024”.
Ensure that your pages work at this point, if they do not, then do not continue. Marks are not awarded
for quantity of work, rather the quality.
The nav bar will contain php, such as to dynamically display either 'sign up and sign in' when no user is logged
in, or 'sign out and the user’s information' when the user is logged in. A link to the home page, headlines and
about me pages also needs to be included. Stylize the nav bar professionally, and there must be a hover effect.
You will notice on each content page, that 'getCookieUser' function is called at the start of the webpage. This
gets the cookie named 'CookieUser'. 'CookieUser' stores the username of the currently logged in user. Once
retrieved it is stored in the php variable $cookieUser. If no user is logged in, then $cookieUser stores "" (see
Functions.php for implementation).
How to implement
If cookieUser is "" then echo the html to show the links to sign up (SignUp.php) and sign in (SignIn.php) Else
echo the html to show the link to sign out (LogOutUser.php) and the cookieUser.
Ensure that your pages work at this point, if they do not, then do not continue. Marks are not awarded
for quantity of work, rather the quality.
Create the html form for SignIn.php such that it asks for the username, using "POST" and directs to
"LogInUser.php" upon clicking submit/login/sign in button. If user enters incorrect username or a username
that doesn’t exist yet, it should print an error message such as “The username ‘xyz’ does not exist” or
something similar.
Create the html form for SignUp.php such that it asks for the username, first name, and last name using
"POST" and directs to "AddUser.php" upon clicking submit/sign up/register button. Add some php code before
the html form, that echo’s $cookieMessage. (This is to display any error messages we will implement later in
this document)
(Pay attention in this part, most of the code is given to help you with later sections)
In AddUser.php:
Check if the data from the POST was provided using 'isset', if not echo an error message such as “UserName
not provided” (This does not need to be formatted).
Else
Trim all of the inputs from the POST and store in php variables, one example is shown below
If the username exists already, set appropriate cookie/error message and redirect to SignUp.php asking user
to sign up with different username.
If there is no match, then you need to prepare, bind and execute an SQL statement to insert the user. Note
that we do not add the UserID as it autoincrements.
Add a cookie message stating the user has been added, and redirect to the homepage.
In HomePage.php:
Add some php code at the start of the content nav, that echos $cookieMessage. When adding a user, you
should see your cookie message “The username ______ has been added. Please sign in to start posting” or
something similar.
Add some welcome information with an image, make the text and image unique (i.e. do not copy what other
students have)
You can use images from: https://unsplash.com/ or any other copyright-free images
See license details here: https://unsplash.com/license
Ensure that your pages work at this point, if they do not, then do not continue. Marks are not awarded
for quantity of work, rather the quality.
In LogInUser.php:
Check if the data from the POST was provided using 'isset', if not echo an error message (This does not need
to be formatted) (Note that only the username is passed this time).
Connect to database using the connectToDatabase() function trim the input from the POST and store in a
php variable
Prepare, bind and execute the SQL command to check if username exists (use 'COLLATE NOCASE' as done
before so that it is a case insensitive search)
If there is a match, this means that a user with this username exists, and the users can log in. Set the
username using the function "setCookieUser()"
Set the cookie message to welcome back the user redirect back to the homepage.
If there is no match, then set the cookie message to inform the user that the username does not exist
redirect back to the sign in page.
PART 7: HTML, CSS AND PHP
In Headlines.php:
Create a heading “Headlines” or something similar. Create a table (and stylize) with header row containing
the columns as shown below:
Inside the table you will need to add php code to add the remaining rows dynamically.
(We order by descending HeadlineID so the last one added appears at the top)
For each row in the database, get the username, datetime and headline
Then create the html to display the row in the table (note that the headline needs to be a link as shown)
$userName = $row['UserName'];
$dateTime = $row['DateTime'];
$headline = $row['Headline'];
echo "<tr>";
echo "<td>$dateTime</td>";
echo "</tr>";
Under the table add the form for "Create a new heading" field.
Add the php code to display the cookie message below this.
Then, if the cookie user is "" then display "You must be logged in to create a heading"
Else display a form using POST that directs to "AddHeading.php".
In AddHeadline.php:
Check if the data from the POST was provided using 'isset', if not echo an error message (This does not need
to be formatted) (Note that only the username is passed this time).
Trim the input from the POST and store in a php variable
Prepare, bind and execute the SQL command to check if headline already exists (use 'COLLATE NOCASE' as
done before so that it is a case insensitive search)
If the headline already exists then set the cookie message to indicate that the headline already exists and
redirect to the Headline.php page
Else
Get the id of the user.
Insert the headline into the database and then redirect back to Headlines.php
Ensure that your pages work at this point, if they do not, then do not continue. Marks are not awarded
for quantity of work, rather the quality.
In Blog.php:
GET the headline name passed, and display this as the heading.
if(isset($_GET['Headline'])){
$thisHeadline = $_GET['Headline'];
else{
redirect("Headlines.php");
Create a table (and stylize) with header row containing the columns as shown below:
Connect to the database. Get the headlineID based on the headline and count the number of posts within
this headline. Get the posts for the headline using the SQL statement. Add the rows to the table.
Add the php code to display the cookie message below this.
Then, if the cookie user is "" then display "You must be logged in to create a post" Else display a form using
POST that directs to AddBlogPost.php?Headline=$thisHeadline
In AddBlogPost.php:
$BlogPost = trim($_Post['NewBlogPost']);
$Headline = trim($_GET['Headline']);
Get the userID and headlineID (You have done both of these before)
Insert the blog post into the database and redirect back to the Blog.php.
….
redirect("Blog.php?Headline=$Headline");
Finally, In About.php - Add some content in About.php page, this content should be related to blog theme
and/or about the individual student creating this blog website.
This section will now allow you to demonstrate your technical employability skills by implementing
additional features. You will need to work out how to do these yourself (you can ask for help from your
tutor/lecturer).
Feature 1. Limit number of headlines and blog posts
Only show a max of 5 headlines and a max of 10 posts at one time. The user should be able to click next page
to see the remaining.
Clicking on 'Headline Name’ sorts the headlines by name, clicking on 'Date Created' sorts the headlines by
date (default)
Delete the cookieUser. This should be simple, and you do not need to connect to the database
To show that your website works and that you can interact with it you must:
Add 10 users