SitePoint
  • Premium
  • Library
  • Community
  • Jobs
  • Blog
LoginStart Free Trial
PHP & MySQL: Novice to Ninja, 7th Edition
PHP & MySQL: Novice to Ninja, 7th Edition
Notice of Rights
Notice of Liability
Trademark Notice
About Tom Butler
About SitePoint
Preface
Who Should Read This Book
Programming Has Changed
It Takes 10,000 Hours to Become an Expert
Resist the Temptation to Skip Ahead
The Concorde Fallacy
You’re Not Learning PHP
Getting Braces and Semicolons in the Right Place Is the Easy Part
You Won’t Get Anything Done by Planning
Where to Find Help
Your Feedback
Let’s Go

1

Installation

Your Own Web Server
Getting Started
Getting Started with Docker
We’re All Set Up
Basic Syntax and Statements
Variables, Operators, and Comments
Control Structures
Arrays
User Interaction and Forms
Passing Variables in Forms
Hiding the Seams
Bring On the Database
An Introduction to Databases
MySQL
Using MySQL Workbench to Run SQL Queries
Creating a Database
Structured Query Language
Creating a Table
Adding Data
A Word of Warning
Viewing Stored Data
Modifying Stored Data
Deleting Stored Data
Let PHP Do the Typing
The Big Picture
Creating a MySQL User Account
Connecting to MySQL with PHP
A Crash Course in Object-oriented Programming
Sending SQL Queries with PHP
Handling SELECT Result Sets
Thinking Ahead
Inserting Data into the Database
Magic Quotes
Prepared Statements
Deleting Data from the Database
Mission Accomplished
Giving Credit Where Credit Is Due
Rule of Thumb: Keep Entities Separate
SELECT with Multiple Tables
Simple Relationships
Many-to-many Relationships
One for Many, and Many for One
Include Files
Custom Functions and Function Libraries
Breaking Up Your Code into Reusable Functions
The Best Way
Improving the Update Function
Handling Dates
Making Your Own Tools
Generic Functions
Using These Functions
Repeated Code Is the Enemy
Further Polishing
Moving Forward
Time for Class
Public vs Private
Protected
Objects
Class Variables
Constructors
Type Hinting
Private Variables
Constructor Property Promotion
Using the DatabaseTable Class
Updating the Controller to Use the Class
DRY
Creating a Controller Class
Single Entry Point
Keeping it DRY
Template Variables
Be Careful with extract
Summary
Search Engine Optimization
Thinking Ahead: User Registration
URL Rewriting
Tidying Up
Reusing Code on Different Websites
Autoloading
Redecorating
Enforcing Dependency Structure with Interfaces
Error Handling
Your Own Framework
Validating Email Addresses
Preventing the Same Person from Registering Twice
Securely Storing Passwords
Registration Complete
Chapter Summary
Cookies
PHP Sessions
Access Control
Creating a Login Form
Logging Out
The Sky’s the Limit
Object Relational Mappers
Tidying Up
Joke Categories
Assigning Jokes to Categories
Displaying Jokes by Category
Editing Jokes
User Roles
Creating a Form to Assign Permissions
Phew!
Regular Expressions
String Replacement with Regular Expressions
Putting It All Together
Sorting, Limiting and Offsets
Achievement Unlocked: Ninja

Community Questions