PHP 101: Introduction to PHP and MySQL

About PHP 101

PHP is the most popular Server Scripting language. It is used to drive many of the largest web sites in the world, and is used to produce dynamic web sites, often driven by a database such as MySQL

MySQL is the most popular open source database, though by no means the only one. It is also behind many of the largest content-based web sites in the world.

This course covers the basic techniques of writing scripts in PHP. It uses modern, best practices, and encourages readable and maintainable code. It also covers the basics of working with a database. Although MySQL is used throughout the course, the material will allow you to easily switch to any of the other popular databases such as PostGreSQL and SQLite.

The PHP techniques covered include:

  • Writing Scripts
  • Including Files
  • Processing Form Data
  • Data Calculations
  • Working with Images
  • Cookies & Sessions
  • Working with Database
  • File Handling
  • Security

Course Outline

At all times, the student is encouraged to follow good design and writing principles, and the examples and exercises are clear and written in a way to facilitate further development.

Throughout the book are summary sections which explain key PHP concepts, and can be used later as a reference. There are also Appendices which expand on the concepts covered in the course.

The course is also available in two smaller parts.

Course Outline

PHP 101: Introduction to PHP and MySQL

Download Course Outline

  • Module 1: Preparing Files
    • Renaming the Files
    • Using PHP to Print Processed Data
    • Including Files
    • A Template File
  • Module 2: Forms & Email
    • Simple Form Processing
    • Re-Entrant Form Processing
    • The Real Contact Form
    • Form Validation
    • Planning for Validation
    • Checking Required Fields
    • Checking an Email Address
    • Handling the Error
    • Persisting Fields
    • Sending the Email
    • Redirecting to Another Page
  • Module 3: Uploading Files
    • The Upload Form
    • Settings
    • Processing POSTed Data
    • Checking the Uploaded File
    • Checking the File Type
    • Handling the Error
    • Persisting Fields
    • Keeping the File
    • Tidying Up
  • Module 4: Library and Configuration Files
    • Configuration File
    • Function Library
    • Classes and Objects as Containers of
    • Functions & Data
  • Module 5: Thumbnails
    • Creating Thumbnails
    • The makeThumbnail Function
    • Loading the Original
    • Saving an Image File
    • Generating the Thumbnail
    • The Upload Page
    • Differently Shaped Thumbnails
    • The Image Gallery
  • Module 6: Database
    • Database Concepts
    • Preparing the Database
    • Users
    • Tables
    • SQL
    • Important Clauses
    • SQL Functions
    • PHP
    • Using the PDO Object
  • Module 7: Sessions & Logging In
    • Sessions
    • Logging In
    • The Admin Page
    • The User Table
    • Preliminaries
    • Checking Login
    • Start (& Continue) a Session
    • Session Data
    • Restricted Area
    • Logging Out
  • Module 8: Adding Images
    • Preparing the Images Table
    • Including the Database Connection
    • Adding Image Data to the Table
  • Module 9: File Handling
    • Preparation
    • Reading Text Files
    • Splitting the Data
    • Processing the Data
    • Copying the Image File
    • Reading a Directory
  • Module 10: The Image Gallery
    • The Image Gallery
    • Outlining the Code
    • Preparing the Page
    • Gallery Page Data
    • Selecting Multiple Image Records
    • Constructing the img Elements
    • Displaying Page Information
    • Paging
    • The Paging Buttons
    • Displaying a Thumbnail
    • Using Cookies to Remember the Page
    • Displaying a Random Image
  • Module 11: Managing Images
    • The Image List
    • Displaying the Image Items
    • Finishing the Page
    • The Image Editing Page
    • Editing Data
    • Deleting Data
  • Module 12: Content Management
    • Blog Table
    • Pages
    • The Editing Page
    • Checking the Submitted Data
    • Inserting Articles
    • Listing Articles & Selecting
    • Deleting Articles

PHP 101a: Introductory PHP and MySQL

Download Course Outline

  • Module 1: Preparing Files
    • Renaming the Files
    • Using PHP to Print Processed Data
    • Including Files
    • A Template File
  • Module 2: Forms
    • Simple Form Processing
    • Re-Entrant Form Processing
  • Module 3: Uploading Files
    • The Upload Form
    • Settings
    • Processing POSTed Data
    • Checking the Uploaded File
    • Checking the File Type
    • Handling the Error
    • Persisting Fields
    • Keeping the File
  • Module 4: Library and Configuration Files
    • Configuration File
    • Function Library
    • Classes and Objects as Containers of
    • Functions & Data
  • Module 5: Database
    • Database Concepts
    • Preparing the Database
    • Users
    • Tables
    • SQL
    • Important Clauses
    • SQL Functions
    • PHP
    • Using the PDO Object
  • Module 6: Adding Images
    • Preparing the Images Table
    • Including the Database Connection
    • Adding Image Data to the Table
  • Module 7: File Handling
    • Preparation
    • Reading Text Files
    • Splitting the Data
    • Processing the Data
    • Copying the Image File
    • Reading a Directory
  • Module 8: The Image Gallery
    • The Image Gallery
    • Outlining the Code
    • Preparing the Page
    • Gallery Page Data
    • Selecting Multiple Image Records
    • Constructing the img Elements
    • Displaying Page Information
    • Paging
    • The Paging Buttons
    • Displaying a Thumbnail
    • Displaying a Random Image

PHP 101b: Intermediate to PHP and MySQL

Download Course Outline

  • Module 1: Forms & Email
    • The Contact Form
    • Form Validation
    • Planning for Validation
    • Checking Required Fields
    • Checking an Email Address
    • Handling the Error
    • Persisting Fields
    • Sending the Email
    • Redirecting to Another Page
  • Module 2: Library and Configuration Files
    • Configuration File
    • Function Library
    • Classes and Objects as Containers of
    • Functions & Data
  • Module 3: Thumbnails
    • Creating Thumbnails
    • The makeThumbnail Function
    • Loading the Original
    • Saving an Image File
    • Generating the Thumbnail
    • The Upload Page
    • Differently Shaped Thumbnails
    • The Image Gallery
  • Module 4: Sessions & Logging In
    • Sessions
    • Logging In
    • The Admin Page
    • The User Table
    • Preliminaries
    • Checking Login
    • Start (& Continue) a Session
    • Session Data
    • Restricted Area
    • Logging Out
  • Module 5: Using Cookies
    • Using Cookies to Remember the Page
  • Module 6: Managing Images
    • The Image List
    • Displaying the Image Items
    • Finishing the Page
    • The Image Editing Page
    • Editing Data
    • Deleting Data
  • Module 7: Content Management
    • Blog Table
    • Pages
    • The Editing Page
    • Checking the Submitted Data
    • Inserting Articles
    • Listing Articles & Selecting
    • Deleting Articles

Student Resources