Preface
1. Chapter 1 Installation
1.1. Your Own Web Server
1.2. Server Setup 1: Manually Installing All the Software Components
1.3. Server Setup 2: Pre-packaged Installations
1.4. Server Setup 3: Virtual Servers
1.5. Your Own Virtual Server
1.6. Installation on Windows
1.7. Installation on macOS
1.8. Installation on Linux
1.9. Getting Started with Vagrant
2. Chapter 2 Introducing PHP
2.1. Basic Syntax and Statements
2.2. Variables, Operators, and Comments
2.3. User Interaction and Forms
2.4. Passing Variables in Links
2.5. Passing Variables in Forms
2.6. GET or POST?
2.7. Hiding the Seams
2.8. PHP Templates
2.9. Many Templates, One Controller
2.10. Bring on the Database
3. Chapter 3 Introducing MySQL
3.1. An Introduction to Databases
3.2. Using MySQL Workbench to Run SQL Queries
3.3. Structured Query Language
3.4. A Word of Warning
3.5. Viewing Stored Data
3.6. Modifying Stored Data
3.7. Deleting Stored Data
3.8. Let PHP Do the Typing
4. Chapter 4 Publishing MySQL Data on the Web
4.1. The Big Picture
4.2. Creating a MySQL User Account
4.3. Connecting to MySQL with PHP
4.4. A Crash Course in Object-oriented Programming
4.5. Configuring the Connection
4.6. Sending SQL Queries with PHP
4.7. Handling SELECT Result Sets
4.8. Inserting Data into the Database
4.9. Deleting Data from the Database
5. Chapter 5 Relational Database Design
5.1. Giving Credit Where Credit Is Due
5.2. Rule of Thumb: Keep Entities Separate
5.3. SELECT with Multiple Tables
5.4. Many-to-many Relationships
5.5. One for Many, and Many for One
6. Chapter 6 Structured PHP Programming
6.1. Include Files
6.2. Including HTML Content
6.3. Including PHP Code
6.4. Types of Includes
6.5. Custom Functions and Function Libraries
6.6. Breaking Up Your Code Into Reusable Functions
6.7. Using Functions to Replace Queries
6.8. Editing Jokes on the Website
6.9. The Best Way
7. Chapter 7 Improving the Insert and Update Functions
7.1. Improving the Update Function
7.2. Stripping the Trailing Comma
7.3. Improving the Insert Function
7.4. Displaying the Joke Date
7.5. Making Your Own Tools
7.6. Using These Functions
7.7. Repeated Code Is the Enemy
7.8. Creating a Page for Adding and Editing
8. Chapter 8 Objects and Classes
8.1. Time for Class
8.2. Public vs Private
8.3. Using the DatabaseTable Class
8.4. Updating the Controller to Use the Class
8.5. Creating a Controller Class
8.6. Single Entry Point
8.7. Keeping it DRY
8.8. Be Careful With Extract
9. Chapter 9 Creating an Extensible Framework
9.1. Make Things Generic
9.2. Thinking Ahead: User Registration
9.3. Make it OOP
9.4. Reusing Code on Different Websites
9.5. Generic or Project Specific?
9.6. Making EntryPoint Generic
9.7. Autoloading and Namespaces
9.8. Implement an Autoloader
9.9. Autoloading with PSR-4
9.10. A Note on Composer
9.11. And the REST
9.12. Enforcing Dependency Structure with Interfaces
9.13. Your Own Framework
10. Chapter 10 Allowing Users to Register Accounts
10.1. Validating Email Addresses
10.2. Preventing the Same Person from Registering Twice
10.3. Securely Storing Passwords
11. Chapter 11 Cookies, Sessions, and Access Control
11.1. Counting Visits with Sessions
11.2. Protected Pages
11.3. Interfaces and Return Types
11.4. Making Use of the Authentication Class
11.5. Login Error Message
11.6. Creating a Login Form
11.7. Assigning Added Jokes to the Logged-in User
11.8. The Sky’s the Limit
12. Chapter 12 MySQL Administration
12.1. Backing Up MySQL Databases
12.2. Database Backups Using MySQL Workbench
12.3. Database Backups Using mysqlpump
12.4. Incremental Backups Using Binary Logs
12.5. MySQL Access Control Tips
12.6. Host Name Issues
12.7. Foreign Keys
12.8. Better Safe than Sorry
12.9. Object Relational Mappers
12.10. Methods in Entity Classes
12.11. Using Entity Classes from the DatabaseTable Class
12.12. Using the Joke Class
12.13. Simplifying the List Controller Action
12.14. Assigning Jokes to Categories
12.15. Assigning Categories to Jokes
12.16. Displaying Jokes by Category
13. Chapter 13 Creating a Form to Assign Permissions
13.1. Edit Author Permissions
13.2. A Crash Course in Binary
13.3. Be Bit-Wise
13.4. Back to PHP
13.5. Storing Bitwise Permissions in the Database
13.6. Join Table or Bitwise
13.7. Editing Others’ Jokes
14. Chapter 14 Content Formatting with Regular Expressions
14.1. String Replacement with Regular Expressions
14.2. Putting It All Together
14.3. Sorting, Limiting and Offsets
14.4. Pagination with LIMIT and OFFSET
14.5. Pagination in Categories
14.6. Achievement Unlocked: Ninja
Appendix A Using The Sample Code Repository
Appendix B Linux Troubleshooting