Need to create a simple web application that tracks boats and their owners for a local marina. The applicationmust include basic page navigationto allow the user to move between all pages that are...

2 answer below »

Need to create a simple web application that tracks boats and their owners for a local marina.


The applicationmust include basic page navigationto allow the user to move between all pages that are accessible by the user.


You should allow a user to:



  1. browse a list of the various boats being moored

  2. view the details on a specific boat

  3. add new boats including an image of the boat

  4. edit and delete existing boats


You will also need to store basic information about eachboat, including:



  1. thenameof the boat

  2. its registrationnumber

  3. length (in metres)

  4. a picture of the boat (you will store a string for the filename of the image)



Each boat is owned by asingle individual, butany one individual could own one or more boats. You need to store each boat owner's:




  1. first name

  2. last name

  3. address

  4. phone number

  5. profile picture (like above, you will store a string for the filename of the image)


You need to be able toadd, edit, and deletethis information along with the boat information, and associate boats with owners.



Notes:



  • Boats and owner information must be stored intwo separate tables. A SQL file has been provided for you to create the database and tables.

  • You must use the provided Database.php file in the classes folder, and build Boat and Owner classes that implement ActiveRecord while extending the Database class. For more information about this, review the lecture for this week.

  • All object/record manipulation must be performed by calling the methods of the Boat and Owner classes. There should be no SQL queries made outside of these objects!

  • Validation / sanitation on all user input!



Folder structure


assignment4-starter-files ├── class │ ├── Boat.php // Boat class │ ├── Owner.php // Owner class │ └── lib // Library folder, don't modify these files │     ├── ActiveRecord.php │     ├── Auth.php │     ├── CSRF.php │     ├── Database.php │     ├── Exception.php │     └── Image.php ├── includes // Feel free to modify these files │ ├── footer.php │ └── header.php ├──uploads // Image Uploads folder, free Bob Ross avatar image for you to start with     └── 1617161780_6063ee34b1f0f.png ├── authenticated.php // Page, authenticated user example ├── editUser.php // Page for user edit, profile image upload example ├── genPwd.php // Page (temporary), password generator example (remove from folder) ├── index.php // Page, homepage, redirect to login example ├── login.php // Page, authentication with CSRF example ├── logout.php // Page, logout session clear example └── schema.sql // SQL schema, remove from folder


Step 1 - Setup and build initial scripts to create Boats and Owners (10 marks)



  • Download the ZIP file containing the starting PHP files and unzip it to a new folder calledassignment4in thecodefolder we've used for all of the labs/assignments.

  • Create the marina database from the providedschema.sqlfile. You can do this with the command-line or using a GUI like Heidi.


    • NOTE:Read through the SQL file as there are lines that are commented that you will need to review before executing the queries!


  • Read through the comments inclass/Owner.phpand complete the class for Owner using the information from above – you should be able to carefully adapt from the Boat class.



Step 2 - Change Owner class to User and modify user table (10 marks)


In the database, change your owner table to a user table, and add columns for:



  • username

  • password

  • user_type (Note assume a value of0represents an Owner type user, and1represents a regular user. We could expand this in the future for example 2 would represent a manager, 3 an administrator etc..)


Rename your Owner class to User, and add support for the three new fields above (declare private fields in the class with the exact same spelling as your database table columns, add setters/getters etc.)


Once you've renamed the class, create a user to test with. There is a handy file you can load in your browser atgenPwd.phpwhich takes a single query string param ofpand will generate a password hash you can use in your database. Example: load this in your browserhttp://localhost:8080/path/to/genPwd.php?p=(change path/to to the real path!)and pass whatever value you want as thepvalue. Copy the output into anINSERTorUPDATESQL query at the bottom of theschema.sql fileto add a new user with your password hash.


Step 3 - Complete the add/edit/deleteboatscripts (10 marks)



Complete the functionality to add, edit, and delete boats - for full marks on Step 3 you have to make sureyou canselect which User owns the boatwhen editing a user. Only users with user_type = 0 should show up in the select/option list on the form (Users with user_type=0 represent 'Owners' rather than regular users). You will also need to allow for uploading and displaying a boat image.



NOTE:the names of the owners should show up in the select list, but you will use the value attribute of the option element to set the id for each user. You need to query the User class for a list of users to display in this list, and the database query code should be in the User class.


Step 4 - Complete the add/edit/deleteuserscripts (10 marks)


Next, make a new script to add, edit, and delete users. You will need a page where new Users can register for the website, including where a Boat Owner will register. The form on the 'addUser.php' page should include fields for all User fields (e.g. firstname, lastname, username etc..) including a checkbox that if checked will create a new 'owner' User with user_type=0, and if not checked the new User will be created with user_type=1, and should also include a way for them to upload a profile image.


From the index.php page, down at the bottom we will include a link to 'editUser.php'.This page will be your user preferences, where if you want to change how your name is spelled you can go to this form, make the changes, and when you submit it will call the User class update function. The form should also include a checkbox to set/unset if this user is an Owner. Selecting an Owner (which will now be a user with user_type=0) should be from a drop down select list.


Step 5 - Use of authentication features (10 marks)


Every page that is not index.php, login.php, or logout.php, should have some form of authentication andshould redirect back to index.php page in the event that it is navigated to manually in the browser.Failure to do this will result in a loss of marks!


Whenever you want to use authentication, you will need to use the Session features in PHP. In order to do this, you need to callsession_start();in every file you want to use sessions and it is VERY IMPORTANT that this is thefirst line in any file you use it!


The login.php and logout.php files, as well as Auth and CSRF classes, have been provided for you.


Step 6 - Make it look professional (10 marks)


Please make theindex.phppage the "homepage" of the application, with a link to log in.


Use Bootstrap or some other CSS framework to make the pages look professional — pretend you are delivering this to a client, imagine how it should look for them. Also feel free to modify all the provided pages to suit your style!


Step 7 - Support uploading/changing Boat images (10 marks)


Support uploading pictures from theadd AND edit boat pages, and then use the uploaded photo as the image for the boat. Please include this for Users as well. Remember to useinput[type=file]!


Show the image as an appropriate sized thumbnail on the page listing all the boats with owner information, and show the full size image on the edit boat pages. To achieve this you will use the stored filename string (the random hash generated when you uploaded the image), and reference that file from theuploadsfolder. An example of this process has been included for you in editUser.php, and includes an example of how to upload an image and display it; use this as needed elsewhere!


NOTE:you don't need to show the selected boat image on the addBoat.php page as the selected image has not been POSTed to the server yet.

Answered 22 days AfterApr 03, 2021

Answer To: Need to create a simple web application that tracks boats and their owners for a local marina. The...

Sanghamitra answered on Apr 20 2021
154 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here