Ron Fredericks writes: I am LectureMaker’s video platform technologist. So I thought I would demonstrate some of my sample code in building a simple website demo.
The demo consists of three pages that feature the following code
- PHP programming with OO and model-view-controller (MVC) architecture
- SQL file to create a new table and load some sample user data
- PHP sessions and OO MySQL Data Manager
- Use of CSS style sheet and tags for web page layout and forms management
- Use of JavaScript and jQuery functions and project library
- A RESTful API allowing users to move data between the three pages
Visit the running project’s website here:
www.lecturemaker.com/test/HP_login.php
Download a copy of the project’s source code from GitHub:
https://github.com/RonFredericks/PHP_Demo_Project
Overview
Build a 2-3 page website with a single page view concept with JavaScript mvc and REST service. The concept of the site is to choose your background. After login the user can select a file to upload and that becomes the background image of the landing page. Page 1 is login with at least 3 different users who can login. Page 2 is landing page which will show the image uploaded and page 3 is upload the background image you like. Page 2 and 3 should have a logout button.
FAQ
What is OOP?
Object Oriented Programming, or OOP, invokes the use of classes to organize the data and structure of an application:
- Objects: instances of a class
- Inheritance: ability to pass characteristics and behaviors from a base class
- Access Modifiers: ability to protect data and methods
- Interfaces: a form of abstract class that acts as a model for creating a derived class
- PHP 5 Built-in Classes: Standard PHP Library (SPL), mysqli, PDO, SQLite, XML support, relfection, Iterator interface, magic methods, objects passed by reference
- Design Patterns: a reusable set of solutions that solve practical problems
What is MVC?
Model–View–Controller (MVC) is an architectural pattern used in software engineering:
- Model handles database logic. Code in the model connects to the database and provides an abstraction layer.
- Controller represents the business (application) logic i.e. all our ifs and else.
- View provides the presentation logic i.e our HTML/XML/JSON code.
What is REST?
Representational state transfer (REST) is a predominant web API design model for distributed systems. PHP examples include:
- Use FORM tag with GET or POST to send data to another web page.
- Use cURL to set the URL, create array of POST data, set options such as return XML data, and make request.
- Create a POST request by opening a TCP connection to the host using fsockopen(), then use fwrite() on the handler returned from fsockopen().