PHP tutorial
Build dynamic websites with server-side code
About this tutorial
PHP runs on the web server and builds pages before they reach the browser. It powers forms, logins and database-driven websites, including this portal.
In this beginner class you install a local server, learn variables, decisions, loops and functions, handle forms safely, remember visitors with sessions, and finally connect to a MySQL database to build a real project. Every lesson has examples, an exercise and a short quiz. Finish with the final quiz.
Lessons
Getting started
- Hello, PHPWhat PHP is, how to run it on your computer with XAMPP, and printing your first output with echo.
- Variables and arraysStore values in $variables, learn the main data types, join strings, and keep lists of values in arrays.
- Operators and stringsDo maths, compare values with == and ===, and use the most useful string functions.
Making decisions and repeating
Functions and files
Working with the web
- Forms: GET and POSTReceive what visitors type with $_GET and $_POST, and learn when to use each method.
- Validating and escaping inputNever trust what visitors type: check every field, show helpful errors, keep their answers, and escape output.
- Sessions and cookiesRemember visitors from page to page with sessions, build a simple login flag and log out, and see when to use cookies.
- Dates, JSON and filesFormat dates, work with DateTime, read and write files, and convert arrays to and from JSON.
PHP and MySQL
- Connecting to MySQL with PDOCreate a database in phpMyAdmin and connect to it from PHP with PDO, handling errors properly.
- Prepared statements: insert, update and deleteSave, change and remove data safely with prepared statements, and see why they stop SQL injection.
- Project: a prayer request boardCombine forms, validation, sessions, PDO and escaping to build a small working web app.
- PHP final quizFifteen questions covering the whole PHP beginner class. Score yourself to finish the course.