Web Development · WDC-01-03

Basic PHP and MySQL

Basic PHP and MySQL is a beginner course in building web applications with PHP 8.5 and a MySQL database, from language basics, forms, sessions and SQL to connecting safely through PDO. It suits newcomers to web programming and students building projects with PHP and MySQL, and you leave able to build a member login and a data management system.

Updated
From 4,410 THB / person 4,900 −10% excl. VAT 7% · group rates available
PDFDownload the course outline
  • Duration18 hours · 3 days
  • FormatOnsite / live online
  • Next roundOn request
  • CertificateIncluded

Course overview

PHP and MySQL still power a great many websites, from internal back-office systems and sites built on WordPress to frameworks such as Laravel. Understanding PHP and databases from the ground up is therefore a good way into web development. Yet much of the sample code found online is outdated: it builds SQL directly from form input, stores passwords in readable form, or uses functions that were removed from PHP long ago, producing websites that work but are full of holes.

This course takes beginners through building web applications with PHP 8.5 and MySQL 8.4 LTS the current way. Learners install the tools on their own machines, build a website template with HTML and CSS, and learn PHP syntax from variables, conditions and loops to arrays and functions. They then handle form input, use sessions and cookies, design a database with phpMyAdmin, write SQL and connect to the database with PDO and prepared statements. The final day builds a create, read, update and delete system and a member system that stores passwords safely, covers protection against SQL injection, XSS and CSRF, and closes with a workshop and publishing the site to a hosting service. (3 days, 6 hours per day, 18 hours in total, Beginner level.)

What you’ll gain

  • Understand the client-server model and set up a PHP and MySQL environment yourself
  • Write PHP 8.5, from variables, conditions, loops and arrays to functions
  • Handle form input and use sessions and cookies safely
  • Design MySQL tables and write commonly used SQL statements
  • Connect to the database with PDO and prepared statements
  • Build create, read, update, delete and search features and a member login system
  • Protect against basic vulnerabilities such as SQL injection, XSS and CSRF

Who this course is for

  • Anyone who wants to start server-side web programming
  • School and university students developing projects with PHP and MySQL
  • Web designers who can write HTML and CSS and want to build database-driven sites
  • Website administrators who need to edit or look after systems written in PHP
  • Anyone planning to study Laravel or WordPress in depth who needs a correct PHP foundation

Prerequisites

  • Basic HTML and CSS; the essentials are reviewed for those without them
  • Able to use a computer, manage files and install or uninstall software
  • No previous programming or database experience is required
  • A Windows or macOS laptop that can run XAMPP, Laragon or Docker Desktop, with permission to install software

Curriculum

Course Details

This course is the 2026 edition of the Basic PHP and MySQL course, rewritten for PHP 8.5 and MySQL 8.4 LTS. It runs for 3 days, 6 hours per day (18 hours in total, 09:00-16:00), as lectures with labs and workshops built on a single sample member and product system throughout. Beginner level. This edition replaces Dreamweaver and AppServ with VS Code and XAMPP, Laragon or Docker, connects to the database with PDO and prepared statements, stores passwords with password_hash, and adds protection against SQL injection, XSS and CSRF. It focuses on procedural PHP for beginners, while object-oriented PHP and more complex systems are covered in Advanced PHP and MySQL. Learners take home a lab guide, source code and sample database files for every lab.

Day 1 Getting Started with PHP

Section 1: Lab: Tools and the Client-Server Model

  • Client-server websites and the roles of PHP and the database
  • Install PHP 8.5, MySQL and phpMyAdmin with XAMPP, Laragon or Docker
  • Set up VS Code with a PHP extension
  • Check phpinfo() and turn on error display during development
  • Lab: a first PHP page that shows a message and the date

Section 2: The HTML and CSS You Need for PHP

  • Page structure and forms for collecting data
  • Basic layout with CSS and Flexbox
  • Splitting the header, menu and footer with include and require
  • Lab: a reusable website template for every page in the course

Section 3: PHP Language Basics

  • PHP tags, echo and comments
  • Variables, data types and constants
  • Arithmetic, comparison and logical operators
  • Strings and inserting variables into text
  • Reading error messages and finding mistakes in code

Section 4: Lab: Conditions and Loops

  • if, else and elseif
  • switch and the match expression
  • for, while and foreach loops
  • Workshop: a grading system based on scores from a form
  • Workshop: a change calculator

Section 5: Arrays, Functions and Dates

  • Indexed and associative arrays
  • Common array functions such as count, in_array and array_filter
  • Writing your own functions with types, default values and named arguments
  • Dates and times with date and DateTimeImmutable
  • Lab: a product list from an array with a calculated total
Day 2 Forms, Sessions and the MySQL Database

Section 6: Lab: Handling Form Input Safely

  • GET versus POST, and using $_GET and $_POST
  • Server-side validation and messages for users
  • Preventing XSS with htmlspecialchars whenever output is shown
  • The Post/Redirect/Get pattern to avoid duplicate submissions
  • Lab: an event registration form with full validation

Section 7: Sessions and Cookies

  • How sessions and cookies differ and when to use each
  • session_start, and storing and clearing session values
  • Secure cookie settings with HttpOnly, Secure and SameSite
  • Flash messages to report the result after saving data
  • Lab: a simple shopping cart with sessions

Section 8: Designing a MySQL Database

  • Relational databases: tables, rows, columns, primary keys and foreign keys
  • Choosing suitable data types, and utf8mb4 for Thai text
  • Creating databases, tables and database users with phpMyAdmin
  • Lab: design member, category and product tables

Section 9: Lab: Commonly Used SQL

  • SELECT with WHERE, ORDER BY and LIMIT
  • INSERT, UPDATE and DELETE with care
  • Searching with LIKE, and summarising with COUNT, SUM and GROUP BY
  • Joining two tables to show products with their category names
  • Importing and exporting databases with phpMyAdmin

Section 10: Lab: Connecting PHP to MySQL with PDO

  • Creating a PDO connection with charset=utf8mb4
  • Setting the error mode to exceptions and handling them with try and catch
  • Prepared statements with named placeholders to prevent SQL injection
  • Fetching data with fetch and fetchAll and showing it in an HTML table
  • Keeping connection settings in a separate file from the pages
Day 3 Building Real Systems Safely

Section 11: Lab: A Create, Read, Update and Delete (CRUD) System

  • A product list page with management buttons
  • One shared form for adding and editing data
  • Deleting data with a confirmation page using POST
  • Searching and paging with LIMIT and OFFSET
  • Uploading product images with file type and size checks

Section 12: Lab: Member System and Login

  • Member registration with a duplicate email check
  • Storing passwords with password_hash and checking them with password_verify
  • Login and logout with sessions and session_regenerate_id
  • Protecting pages that require login, and separating admin and user rights
  • Workshop: a member page that shows each user's own details

Section 13: Basic Security for PHP Websites

  • SQL injection and XSS: try the attack, then fix the code
  • Preventing CSRF with tokens in forms
  • Hiding errors in production and writing them to a log instead
  • An overview of common risks from the OWASP Top 10
  • A security checklist before putting a site live

Section 14: Keeping Code Maintainable and Using AI Well

  • Organising configuration files, shared functions and pages
  • An overview of what is new in PHP 8.4 and 8.5 that beginners should know
  • A first look at Composer for installing libraries
  • Using an AI assistant to explain and review code, and always checking security yourself

Section 15: Workshop: A Product Management System on Hosting

  • Workshop: bring the member system, product system and back office together
  • Test the system and fix common problems
  • Publish to hosting: upload files, create the database and configure the connection
  • Present the work and plan next steps with Advanced PHP, OOP and Laravel

Schedule & training options

For individuals — public rounds

No public rounds are open right now. Join the waiting list and we will contact you first when the next round opens, or ask us on LINE. Or call 02-570-8449 or 088-807-9770

For organisations — in-house / private

  • Tailor the content to your team’s tools and projects
  • Your dates, at your office or live online
  • Quotation with tax ID for procurement
Corporate training quote

Instructors

Frequently asked questions

What is the difference between sessions and cookies in PHP?

A cookie stores data in the user's browser, so it can be seen or changed, which makes it suitable only for non-sensitive data such as a chosen language. A session stores data on the server and the browser only holds a session ID, so it suits login state and shopping carts. In both cases, cookies should be set with HttpOnly, Secure and SameSite, and the session ID should be regenerated with session_regenerate_id after login.

What are the steps to build a login system with PHP and MySQL?

Create a users table in MySQL that stores passwords hashed with password_hash(), then build a form for the email and password. Use PDO with a prepared statement to look up the user and check the password with password_verify(). On success, regenerate the session ID and store the user's details in the session, check the session on every protected page, and add a logout that clears the session completely.

What is phpMyAdmin and what is it used for?

phpMyAdmin is a web-based tool for managing MySQL and MariaDB databases through a visual interface. You use it to create databases and tables, set column data types, add, edit and delete data, try out SQL statements, and import and export databases, which makes it ideal for beginners who want to see the database structure clearly before writing code.

Who is the Basic PHP and MySQL course for, and what should I know beforehand?

It suits anyone who wants to start web programming, students working on projects with PHP and MySQL, and web designers who want to build database-driven sites. You can start without any programming experience, though some HTML and CSS will help you move faster, and the essentials are reviewed during the course.

What will I be able to do after the Basic PHP and MySQL course?

You will be able to write PHP 8.5 from basic syntax to functions, handle form input safely, use sessions and cookies, design a MySQL database and connect to it with PDO, build create, read, update, delete and search features and a secure member login, and publish the site to hosting. You will also be ready to move on to Advanced PHP, OOP or Laravel.

Which software is used on the Basic PHP and MySQL course?

You use VS Code to write code, and XAMPP, Laragon or Docker to turn your machine into a web server with PHP, MySQL and phpMyAdmin in one package. All of these tools are free, and installation and setup are done together at the start of the course.

Related articles

Articles are published in Thai.