Course Description
This class will introduce you to the basics of PHP and MySQL, with emphasis on learning PHP syntax, conditional statements, arrays, loops, strings, functions etc. You will work with forms, sanitize user input for security, send emails, work with cookies to collect information, and upload files. You will use phpMyAdmin to build your database and tables and write SQL queries to fetch, insert, update, delete, and search records.
Objectives
Upon successful completion of this course, you will be knowledgeable in:
• Basic PHP Syntax
• Working with PHP Numbers
• Conditionals
• Loops and Arrays
• Working with Strings
• Functions & Objects
• Form Basics and Security Agenda
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
Escaping Characters
Heredoc
Concatenation
Comments
Working with Numbers
In this exercise, we will show you how PHP works with numbers.
Arithmetic Operators
Assignment Operators
Table of Arithmetic Operators
Table of Assignment Operators
Defining a Site and Testing Server in Dreamweaver
Conditionals
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.
If/Else
Elseif
Switch
Comparison Operators
Logical Operators
The Difference Between == and ===
Arrays
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
Using array()
Multidimensional Arrays
Printing an Entire Array Using print_r()
Loops
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.
While Loops
Do...While
For Loops
ForEach
Break Out of Loop
Continue
Working with Strings
Let’s explore some basic string functions.
Comparing Strings
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.
Functions
Arguments
Objects and Properties
Objects and Methods
Private Properties
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
Magic Quotes
Securing the page
Sending Email
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.
Sanitizing Input
Error Checking
Displaying Errors
Sending Email
Adding a Thank You Page
Including Files
Cookies
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.
Adding Cookies
Tracking the Number of Visits
Sending an Email with the Cookie Info
Sessions
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
File Uploads
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
Uploading Files
Basic Security
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
SQL Basics
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.
Error Checking
Making an Include
Sorting Results
Prepared Statements
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
SQL: Insert
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
Using phpMyAdmin
Inserting Information from a Form
SQL: Update
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
Update Form
Display Data in the Update Form
Display Checkboxes
Hidden Fields
SQL: Delete
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
SQL: Search
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.
Wildcard Searches
Searching with a Form
Comments
Office Policy: In fairness to all participants, anyone arriving more than 30 minutes late will be rescheduled for another class date.
Cancellation Policy: No Shows: If you are registered for a class and do not attend and fail to contact our office to cancel or reschedule, a fee equivalent to your daily rate will be applied.
Rescheduling: Productivity Point reserves the right to cancel or reschedule any training course.Should we reschedule a course, a full credit will be applied to the rescheduled course. Productivity Point cannot assume responsibility for any other costs to the student (i.e.non-refundable airline tickets). Class credits are redeemable for up to 1 years.
Cancellations: There is no charge for cancellations that are made Ten (10) or more business days prior to the scheduled training date. Cancellations that are made nine (9) business days or less of the scheduled training date are considered “late cancellations” and the full price of the class will be charged.All training cancelled within 10 or more business days' notice will have a credit on account in the full amount of purchase. This credit can be applied to any Productivity Point products or services for up to 1 year from the date of original transaction. There are no refunds.