Skip to content

PHP Course for Beginners

Learn PHP step by step in 14 practical lessons: variables, conditions, loops, arrays, functions, includes, forms, validation, email, sessions and MySQL, ending with a contact form that saves messages to a database.

Intermediate 5 chapters 14 lessons Free
YOUR PROGRESS0%
/ Course content

5 chapters · 14 lessons

Every chapter and lesson has its own page. Open a chapter to see its lessons.

1 Chapter 1: PHP Basics3 lessons

Run your first PHP script, store data in variables and make decisions with if and else.

01Your First PHP Script (Hello World)Coming soon 02PHP Variables and StringsComing soon 03PHP If Else StatementsComing soon
2 Chapter 2: Loops, Arrays and Functions3 lessons

Repeat work with loops, store lists in arrays and package code into reusable functions.

04PHP Loops: for, while and foreachComing soon 05PHP Arrays ExplainedComing soon 06PHP Functions for BeginnersComing soon
3 Chapter 3: Building Pages With PHP2 lessons

Share one header and footer across every page and learn how browsers send data to PHP with GET and POST.

07How to Include Header and Footer in PHPComing soon 08PHP GET vs POST ExplainedComing soon
4 Chapter 4: Forms, Email and Sessions4 lessons

Build a working contact form, validate and sanitize what people type, send email and remember visitors with sessions.

09How to Make a Contact Form in PHPComing soon 10PHP Form Validation and Sanitizing InputComing soon 11How to Send Email With PHPComing soon 12PHP Sessions ExplainedComing soon
5 Chapter 5: PHP and MySQL2 lessons

Connect to a MySQL database with PDO and save your contact form messages safely with prepared statements.

13How to Connect PHP to MySQL (PDO)Coming soon 14Save Form Data to a MySQL Database With PHPComing soon

What you’ll learn

  • How PHP runs on a server and turns code into the HTML a browser sees
  • Variables, strings, conditions, loops, arrays and functions
  • How to reuse a header and footer across every page
  • The difference between GET and POST, and when to use each
  • How to build, validate and secure a contact form
  • How to send email from PHP and remember visitors with sessions
  • How to connect to MySQL with PDO and save form data safely

Who this course is for

  • Web designers who want working forms instead of “contact form plugins”
  • WordPress users who want to understand theme files and edit them with confidence
  • Front-end beginners who know HTML and CSS and want to add a back end

Before you start

Do I need to know HTML first?

Yes, the basics. PHP builds HTML pages, so you should be comfortable with tags, links and forms. The free HTML course on this site covers everything you need.

Is PHP still worth learning?

Yes. PHP runs WordPress, WooCommerce and a large share of the web. If you build or fix websites for clients, you will meet PHP all the time.

What do I need on my computer?

A code editor (VS Code) and a local server. The first lesson shows two free ways to run PHP on your own computer.

What will I build?

A small multi-page site with a shared header and footer, and a contact form that validates input, sends you an email and saves every message to a MySQL database.

Anmol Sharma
Written by Anmol Sharma

Freelance UI/UX designer and web developer. 6 years, 50+ projects, clients in 30 countries. Hire me.