SitePoint
Blog
Forum
Library
Login
Join Premium
Toggle sidebar
PHP & MySQL: Novice to Ninja, 7th Edition
Toggle community discussions
Close
Content
Files
Bookmarks
Preface
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
Introducing PHP
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
Introducing MySQL
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
Publishing MySQL Data on the Web
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
Relational Database Design
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
Structured PHP Programming
Include Files
Custom Functions and Function Libraries
Breaking Up Your Code into Reusable Functions
The Best Way
Improving the Insert and Update Functions
Improving the Update Function
Handling Dates
Making Your Own Tools
Generic Functions
Using These Functions
Repeated Code Is the Enemy
Further Polishing
Moving Forward
Objects and Classes
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
Creating an Extensible Framework
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
Allowing Users to Register Accounts
Validating Email Addresses
Preventing the Same Person from Registering Twice
Securely Storing Passwords
Registration Complete
Chapter Summary
Cookies, Sessions, and Access Control
Cookies
PHP Sessions
Access Control
Creating a Login Form
Logging Out
The Sky’s the Limit
Relationships
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!
Content Formatting and Pagination
Regular Expressions
String Replacement with Regular Expressions
Putting It All Together
Sorting, Limiting and Offsets
Achievement Unlocked: Ninja
Open text modal
Community Questions
Close