Basic PHP Syntax
This exercise gets you started with the basics of PHP syntax. If you don't have previous programming experience, you will find that PHP is pretty simple to learn.
Echo, Strings, and Variables
Single Quotes vs. Double Quotes
Working with Numbers
In this exercise, we will show you how PHP works with numbers.
Table of Arithmetic Operators
Table of Assignment Operators
Defining a Site and Testing Server in Dreamweaver
Conditional operators will be one of the most-used elements of your programming life. Simply put, conditional operators are a way to choose when certain things happen. For example, if something is true, then do something. If it is not true, do something else.
The Difference Between == and ===
One of the most common and powerful types of variables is called an array. There are many ways you can create, output, and manipulate arrays, but here we will just focus on some of the most commonly-used basics.
Creating a simple array
Printing an Entire Array Using print_r()
Loops are an incredibly important and often-used element of your programming tool belt. Here we will explore the many kinds of loops PHP has to offer.
Break Out of Loop
Working with Strings
Let’s explore some basic string functions.
Converting to Upper and Lower Case
Searching Through Strings
Case-Sensitive and Case-Insensitive
Functions & Objects
In this exercise, you will learn the basics of functions and how to use arguments within them. We will go over how to create objects with properties and methods. We will explore the differences between public and private properties, and how to extend classes' functionality.
Objects and Properties
Objects and Methods
Creating Classes that Extend Classes
Form Basics and Security
In this exercise, we will cover the basics of PHP form submission. You will learn the difference between POST and GET, how to deal with radio buttons, checkboxes, and select fields, and how to secure your pages from attacks.
Setting up a basic form
Post vs. Get
Radios, Checkboxes, and Select Fields
Securing the page
One of the great things about PHP is how easy it is to send an email. In this exercise we will show you how to set up MAMP Pro or XAMPP to send test emails.
Setting Up MAMP Pro
Setting Up XAMPP and Mercury Mail
Sending a Test Email
Simple Form Validation and Email
This exercise will focus on a very simple form validation script that checks for simple errors, sanitizes input, and sends an email.
Adding a Thank You Page
Every website should use analytics to track where visitors come from and find information such as their landing page, how many times they have visited, where they came from, etc. and store it in a cookie.
Tracking the Number of Visits
Sending an Email with the Cookie Info
In this exercise we will create a simple login/logout application where we make a few pages password-protected.
Starting a Session
Using Session Variables
Log In/Log Out
Destroying Session Variables
In this exercise we will show you some very basic security measures as well as how to upload files. If you add this type of capability on your live site, it should be in a password-protected area or authenticated in some way.
Making a File Upload Form
The $_FILES Array
Creating a Database/MySQL/SELECT
In this exercise, you’ll learn how to create a database in the phpMyAdmin control panel, as well as how to connect to a database and display some data.
Creating a New Database
Connecting to the Database
The SELECT Statement
Display the Number of Rows Returned
Making a Reusable Connection Script
MySQL vs. MySQLi vs. PDO
Making a Reusable Connection Script
Because we will be connecting to the same database from several webpages, it makes sense to save the connection script into another page. That way, we can just include it at the top of any page that needs to connect to the database.
Making an Include
In this exercise we are going to show how to select a certain row of data in a database. We will select all the records in the database that are equal to a certain email.
Selecting and Filtering Results
Preventing SQL Injection Attacks with Prepared Statements
Interacting with a database wouldn't be much use if we couldn't add data to it. Here you will learn how to insert records into a database using prepared statements.
The INSERT Statement
Inserting Information from a Form
This exercise will show you the SQL syntax for updating a record in a database as well as how to use a form to update user information including checkboxes and hidden fields.
The UPDATE Statement
Display Data in the Update Form
This exercise shows you how to delete records from a database.
The DELETE Statement
Deleting Rows from a Database
Passing ID Variables in a URL
There are an enormous number of ways to search for information in a database. We will show how to perform a basic wildcard search on a column.
Searching with a Form