Code Monkey home page Code Monkey logo

chinook's Introduction

LTW Example

Based on a simplified version of the Chinook Database:

You can see previous versions of the example by changing branches.

Step 1: Create the Database

To create the database, we need to run the following command:

sqlite3 database.db < database.sql

Step 2: Draw Mockups

Draw some initial mockups. Don't lose too much time with these:

Step 3: HTML in PHP files

Step 4: Create template files

What's New

Create a templates folder that will contain several template files.

Each template file will have functions that will be able to draw parts of the HTML:

Step 5: Style folder

Create a css folder that will contain all files related to style of the web page.

Step 6: Documents folder

Create a docs folder that will contain all files related to the documentation.

Step 7: Connect to the database

What's New

Create a database folder that will contain all database pertinent files:

Step 8: Use classes

What's New

Transform all data access functions into classes:

Each class has one or more functions to get data from the database.

Step 9: Log In / Log out Actions

What's New

  • Start a session on every page using session_start().
  • Create a class to get customer data: database/customer.class.php.
  • Create the action_login.php page that:
    • Receives a username and password, verifies if they exist in the database.
    • If they do, saves the customer data to the session.
    • Redirects the user back to the previous page.
  • Show a logout form if the user is logged in.
  • Create the action_login.php page that destroys the session.

Step 10: Edit Profile

What's New

  • Add a new profile.php page that shows a form to edit the profile of the current user.
  • Make sure it does not show if no user is logged in.
  • Add a link from the logout form to the new page.
  • Add a new action_edit_profile.php action page that receives the first and last name and saves them to the profile of the current user.
  • Make sure nothing happens if no user is logged in.
  • Add a function to save customer data.
  • Create a template to edit a profile.

Step 11: Responsive

What's New

  • Add responsive viewport to HTML head.
  • Set maximum width of body.
  • Add a media query for smaller screens.

Step 12: Ajax Search

What's New

  • Added an api_artists.php page that returns a list of artists with a name starting with a specific string in JSON format.
  • Added a function to get artists starting with a specific string from the database.
  • Added a search input box to search artists.
  • Added some CSS to format the search input box.
  • Added a new JavaScript file and included it from the header template.
  • Added an event listener to the search input that fires every time the input changes and:
    • Gets the 'api_artists.php' page using Ajax (with fetch), sending the text in the input.
    • Uses the returned results to update the list of artists.

Step 13: Messages

What's New

First some organization:

Adding messages:

  • Added a Session class responsible for all things session-related, and replaced all direct calls to session_start, session_destroy and $_SESSION to calls to this class.
  • Added a way to store messages in the session.
  • Show all session-stored messages on all pages (HTML and CSS).
  • Added some success and error messages.

chinook's People

Contributors

arestivo avatar

Stargazers

Guilherme Silva avatar Raquel Fernandes avatar Gonçalo Barroso avatar Tiago Ferreira avatar  avatar  avatar aifoS anA avatar Ricardo Yang avatar  avatar Athos Freitas avatar  avatar  avatar Emanuel Maia avatar Tomás Sucena Lopes avatar  avatar Vicente Lora avatar Ana García Arnaiz avatar Daniela Tomás avatar Gonçalo Marques avatar Ana Cristina Ramos avatar Francisco Prada avatar Tiago Devezas avatar Nuno Pereira avatar Pedro Ramalho avatar Vinícius Corrêa avatar Milena Gouveia avatar Isabel Amaral avatar

Watchers

 avatar James Cloos avatar  avatar Hugo Gomes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.