Overriding Principles and Best Practices

Creating A Content Management System (CMS)

Any good CMS will have five key functionalities:

  1. ADD – create a new record
  2. VIEW – view existing record(s)
  3. EDIT – update a existing record
  4. DELETE – delete an existing record
  5. SEARCH – search for existing record(s)

In this training module, we will implement these functionalities.

To make pages more secure, user authentication pages can also be implemented:

  1. Login – allow users to login
  2. Logout – allow users to log out
  3. Registration – allow users to register

Introduction

SPECIAL NOTE: Generic terms will be used (e.g., delete_page.php instead of deleteEmployeePage.php) in the main code to make the code reusable. For example, generic terms can refer to employee, student, worker, etc. So if you wanted to make another app from this one, you would not have to update these references since they are generic.

All the CRUD operations (create, read, update, and delete) will be done on separate pages. The front end work is done with HTML, CSS, jQuery, and jQueryMobile. The back-end work is done with a mySQL database using PDO (PHP Data Objects) extensions to help connect to the database and perform the select, insert, update, and delete operations using prepared statements.

CORNELIUS’ CONCISE CONDENSED CRUD GRID

 

C

R

U

D

CRUD Operations

Create

Read

Update

Delete

App Functions

Add

View

Edit

Delete

SQL Statements

INSERT (INTO)

SELECT (fetch)

UPDATE

DELETE

All operations, functions, and statements deal with getting and setting records from a database. (e.g., create record, add record, insert record, etc.). Sometimes you see the acronym SCRUD where the “S” represents Search (e.g., search or filter a record or records from a database)

To recreate a CMS you typical create a series of pages that include recordset(s) (sometimes called resultsets), business logic code with SQL statements, etc.

Below is a summary of what is typically needed when creating these pages:

  Page Recordset(s) Needed Record(s) Returned SQL Statement SQL Filter
1 master_page.php 1 Many SELECT N/A
2 detail_page.php 1 1 SELECT WHERE
3 add_page.php 1 N/A* INSERT WHERE
4 edit_page.php 2 1 SELECT / UPDATE WHERE
5 delete_page.php N/A N/A DELETE WHERE
6 search_page.php 1 One to Many SELECT WHERE
7 index.php (Login) 1 1 SELECT WHERE
8 logout.php (LogOut) N/A N/A N/A N/A
9 registration_page.php 1 1 INSERT WHERE
* Not applicable unless you want to dynamically populate form elements. The logout does not use any SQL.