
Learn PHP and MySQL to build dynamic websites through seven belt-level training that starts with fundamentals and progressively builds databases, membership systems, and practical apps.
Prepare your php development toolkit by installing Notepad++ and setting up Wamp server, then create, save, and test php files in the 3w folder using localhost.
Explore the anatomy of a typical php file, including start and end tags, php statements, the required semicolon, and comments with //, #, or /* */.
Computer is invented to process data.
To better handle data, data has been divided into several types.
As a programmer, whenever you see the word data, ask two questions: data type and data value.
PHP has offered us a basket to store values. The basket is called variable.
You will learn how to create a variable and how to assign value to it.
when it comes to handling variable, single quotes and double quotes behave differently.
A new data type: NULL.
Assigning NULL to a variable can empty that variable.
you might think value assignment between variables are simple, but there might be things you not know.
Pass value by reference.
The ampersand can tie two variables to one value.
this is the end of the yellow belt, before you move on, you might want to slow things down a little bit and do a review of what you have learnt so far.
A review of what you have learnt in the Yellow Belt Lessons. and also hope you like the music.
A review of what you have learnt in the Yellow Belt Lessons.
The building stone of PHP is expression.
The tool we can use to process data: operator.
Practice uses assignment, string, arithmetic, and comparison operators through variable creation, string concatenation, numeric calculations, and precedence testing to reinforce PHP operator syntax and outcomes.
Give your program a steering wheel so that it can make decisions.
The IF statement.
How to use it and how it works.
Sometimes the program needs to make decisions based on variable values.
In this case, IF statement is not convenient.
SWITCH statement.
What kind of value will be regarded as FALSE.
Ternary operator.
WHILE statement.
How to let the program do repetitions.
Show how a while loop echoes a message while condition is true and increments counter to ten. Initialize a variable to 1, test var <= 10, then echo and increment.
There is another form of WHILE statement: do while.
Another form of LOOP statement: FOR statement
Explore how pre and post increment work in PHP, compare auto increment nuances, and apply plus-equals and string concatenation to manipulate variables and strings in dynamic websites.
The reason why making web apps using PHP is fast and convenient is because of all the brilliant built-in functions PHP has.
But as new learners, there might be some tricky parts about functions.
Always remember the key in using a function is that you have given each function argument a correct value and most importantly, you have put those values in the correct order.
sometimes, you just have to create your own functions, this lesson will teach you how to do that and how to do that properly.
normally, the value returned by a function is NULL. but sometimes, you need control the returned value because the following operations will depend on that.
the keyword RETURN also means the end. Codes behind it will not be executed. In the future, you will find that RETURN is a brilliant tool and you will use it a lot.
changing variable value is simple, but if you want to do that using a function, things are a little bit more complicated.
inside and outside a function, there are two different worlds. Using the keyword GLOBAL, you can break that wall.
you can set default values to function arguments. But if you want to do that properly, there are some rules you must follow.
Create constants in PHP with define, learn naming rules, and that a constant's value cannot be changed, with default case sensitivity and optional true to make it case insensitive.
Learn to create PHP constants with define function, using the first argument as a string name and the second as value. The third argument defaults to false for case sensitivity.
Compared with variable, array is much more powerful, In the future, you will probably use more arrays than variables.
array is powerful, but to use it, you must use a tool: the foreach loop statement
Explore foreach demonstrations on PHP with indexed arrays and associative arrays, learning how to iterate over values and key-value pairs in dynamic websites.
Explore how foreach splits arrays, including multi-dimensional arrays, and why echoing an array fails. Build a recursive function to echo all values, using the array function to test for arrays.
Learn essential php array functions, including count, is_array, in_array, array_combine, array_merge, array_shift, and array_pop, and understand loose versus strict comparisons and default values.
callback can be very helpful sometimes, but its concept is a little tricky to understand.
Explore how PHP's array_walk applies a user supplied function to every array element, using value as first argument, key as second, and an optional third value, with by-reference updates.
there is no way you can put all your codes in one file. but if you write your codes in different files, how do you allow those files to exchange information with each other???
to achieve cross-file communication, you must be able to locate each file.
you will be using array almost all the time in the future. This means you will constantly do all kinds of manipulations to arrays.
converting array into a string is the fist conversion technique you need to learn.
sometimes, you might need to convert a string into an array, so how to do that?
there is another way to convert a string into an array.
Build a PHP file type detector by exploding the file name and using array_pop to get the last element as the extension.
if you need a part of a string, how do you get that???
Use the string replace function to swap zeros with the word zero in a string, using four arguments (last optional) and track replacements with a counter.
Learn to verify email addresses using preg_match with regular expressions, and master pattern design basics, anchors, character classes, quantifiers, and escaping.
Learn how curly bracket quantifiers specify exact or ranged repetition, use backslash shortcuts like \w, \W, \d, and practice greedy versus non-greedy matching, word boundaries, and basic email validation patterns.
you will learn something that will make you feel quite powerful: how to use PHP commands to create files.
how to open a file and how to close a file.
if you want to know the content of a file, how do you get that?
if you want to put new contents into a file, how do you do that?
here are four functions you are recommended to learn by yourself. I will teach you how to use those four functions in the next lesson, but for now, try to learn them all by yourself.
Use file exist to check if a file or directory exists. Use file to test a regular file, file size to get the file size, and unlink to delete.
this bluebelt demonstration creates file.txt, writes 1 through 0, and uses file_exists, filesize, and unlink to verify existence, measure size, and delete the file.
Learn how feof() tests the end of a file in PHP, and how separate read and write pointers track progress for safe handling of large files.
how do you read a large file efficiently?
how to copy, relocate and rename a file
Develop a PHP program to record how many times a web page is visited or refreshed by creating a new file in write mode and using the auto increment operator.
Track web page visits by storing a counter in a text file, updating on each visit, handling the first visit when the file doesn't exist, then reading and incrementing.
to manage files, you need to have file folders or directories. so how to create them?
Use the make directory function to create folders, returning true on success, false on failure, with four arguments including the folder name, a mode (default ignored), and a recursive option.
Rename a directory using the rename function with old and new names, returning true on success. Delete a directory with the r and d function by providing its name, and test if a name is a directory with the is dir function, returning true or false.
Open, read, and close a directory to reveal its contents, learning that each read returns a name, not the path, and that dot and dot-dot denote root and parent folders.
Discover how to delete the nation directory and all its contents by using the unlink function with MDI, and apply recursion to remove files and empty directories before deletion.
BlueBelt shows how to delete directories and files together using a recursive super delete function that traverses a directory, unlinks files, and removes the nation directory once empty.
Advance to the purple belt by reviewing prior lessons and building on the fundamentals of php and mysql, reinforcing continuity and ongoing learning.
although you are a back-end programmer, there are certain front-end techs you just have to know
Display two images in the browser, resize them, and use the alt attribute; wrap the images in an anchor tag to link to the destination url.
Discover how to send data with form and input tags using action and method, choose post for passwords and get for others, and read submitted data from the global array.
Learn how to send and receive form data with an HTML form and process.php using post, with username and password inputs, and $_POST in PHP to echo values.
Compare the get and post methods, noting data visibility in the URL and passwords; use post for sensitive information, while get offers convenient hyperlink data transfers.
Use the get method to send data with a hyperlink by placing a question mark, then the username and password, with ampersands separating values to the destination process.
Learn to upload a file with a PHP form, using an input named upload, configure max file size, inspect $_FILES for size and tmp_name, then move_uploaded_file to destination.
Upload a photo to a destination folder using a PHP form with a 30 megabyte limit, validate the submit, and move the uploaded file with move_uploaded_file; confirm success.
Learn to secure file uploads by implementing security checks, organizing storage, and renaming files properly to mitigate risks when users upload to your server.
Control server and browser side limits on file uploads by setting upload_max_filesize and post_max_size, adjusting the files_uploader checks, and ensuring the browser input precedes the upload tag to enforce size limits.
Learn to validate uploaded file types in PHP by using the switch statement on the global upload array, accepting image/jpeg and exiting on illegal types.
Rename each uploaded file to a unique name by extracting the original extension and using a time-based value with a random number to prevent overwrites.
Rename uploaded files with time and rand, create folders by year month date using the date function and mkdir recursive, and enforce multipart/form-data uploads with size and type checks.
Rename uploaded files using time and rand, extract extensions with explode and array_pop, and create year and month directories with mkdir for successful uploads.
Explains how to download a file by using the head function to tell the browser to download, specify the file size and name, and read contents with a while loop.
Display six pictures, convert each into a get method download link, send the picture name via a global array, build its url, and trigger the browser to download.
Identify and fix download program weakness by validating the file path against a whitelist of downloadable files, using safe get data and implementing checks to prevent unauthorized downloads.
Learn why object-oriented programming should come before MySQL in PHP development to store file ownership and retrieval in a database; MySQL is powerful, popular, and free.
learn object oriented programming by understanding objects as data types and how to declare them; compare procedural programming and see how OOP lets you write less and reuse more.
Refactor a file upload program into object oriented modules and classes, covering error and type control and file handling. Learn the one class one independent file rule and naming conventions.
Learn how to create a class in PHP, where a class is a factory that holds public properties and methods to store and process data.
Discover how to instantiate a PHP class, assign properties, and call its methods using the new keyword with arguments in parentheses and a return object in a receiving variable.
This lecture shows how to create a PHP class, declare properties and methods, set a default value, instantiate the class with require and new, and call methods with arguments.
Learn how to implement a single method, called super assign, to initialize five class properties at once in an info class, improving efficiency for PHP and MySQL dynamic websites.
Master how the __construct() method automatically runs when a class is instantiated, assigns values via constructor arguments, and how __destruct() automatically closes files.
Explore the MySQL database and the MySQLi class in PHP, understanding databases as warehouses with tables, columns, and rows, and learn to navigate their structure and core concepts.
Learn to operate and manage databases with phpMyAdmin, create databases and tables, set collation to UTF-8 for multilingual sites, and navigate the WAMP-based interface to view table structures.
Create a table in the admin page, then define field names and types: date/time, text, numbers, enum, and set, learning length, storage limits, and signed versus unsigned integers.
Explore the 30 MySQL data types across date and time, numeric, and string categories, and learn how storage size, fixed versus variable length, and length attributes affect database design.
Create a new database and a table, set the primary key field with autoincrement, and define engine and transmission fields with appropriate types and lengths, plus storage options and collation.
Instantiate the mysqli class and connect to localhost database using either the connect method or the constructor. Operate four actions—insert, retrieve, delete, and update—after establishing the connection and before disconnecting.
Demonstrates connecting to a MySQL database in PHP using the construct method (localhost, root, car) and the connect method, checking success, suppressing errors with @, and disconnecting with close.
Learn to retrieve data with SQL select statements, use back quotes for identifiers and capitalization for readability, then execute the query and fetch results with fetch array or fetch row.
Demonstrate retrieving six rows from car info table by connecting to the database, preparing and executing a select query, fetching results with fetch array in a loop, and freeing resources.
Learn to organize retrieved data using SQL limits and conditions, selecting specific rows with start index 0, where clauses, and like patterns with a percent wildcard.
Learn to organize retrieved data with limit, apply group by and order by in sql, use asc and desc, and sum mileage by brand for Toyota.
Use mysqli to retrieve and display data: instantiate mysqli class, connect, prepare and execute a select, fetch with fetch_array or fetch_row, free and disconnect, applying where, group, order, and limit.
Learn how to update and delete rows in a MySQL database with PHP, using where and limit 1 to protect data, and how the query method returns true or false.
Insert a new row into a MySQL table using PHP, by preparing an insert statement, collecting form data via post, validating inputs, and executing the query to add the record.
Learn to validate and filter user input with regular expressions, controlling content and length, and escape all special characters before database insertion to prevent sql injection.
Master four database operations and connect using the connect or construct method, handle errors, and use the query method for retrieval, insert, update, or delete with where and limit safeguards.
Learn to use a built-in function to encrypt passwords into 32-character hex strings, create a membership user table, and implement registration and login with email uniqueness and password rules.
Create a PHP and MySQL registration system collecting name, email, password, and confirm password, validating with regex, length 6–20, checking duplicates, hashing with md5, and inserting into membership user table.
Escape the email with the slushes function, prepare and run an sql query to fetch the user by email, then verify one matching row and encrypted password.
build a login program that uses post, validates inputs, connects to a MySQL database, encrypts and compares passwords, and authenticates users before granting access.
Learn how to complete a PHP membership system by creating a private home page, redirecting with window.location, and solving login-required access and username display from the database.
Explore how a university balances access control by using ID cards for general entry and fingerprint scanners for sensitive areas, combining cost and safety for robust security.
Explain cookies and sessions as web identity tools: cookies stay on the browser, sessions live on the server, with admins using sessions and ordinary users relying on cookies.
Learn to create and manage cookies in PHP with setcookie(), set a name and value, use the time function plus seconds for expiry, and delete by expiring in the past.
Learn how to use the set cookie function to control cookie availability with name, value, expiry, and path, then refine domain, secure, and httponly settings.
Set two cookies, user id and security, after login and place a cookie scanner on every page to verify the token against an encrypted md5 value retrieved from the database.
Create an id card and a card scanner, implement cookie-based authentication for user id and security, validate the user against the database, and verify the md5 password to grant access.
Learn to securely log out by revoking the id card, expiring cookies with setcookie to time() minus one, and ensuring the correct path, after verifying login state before logout.
Add a new function to the membership system, implement a file upload flow, and verify successful uploads including file types, folders, and automatic renaming within the index workflow.
Create a picture table to store file names and link each image to a user via user_id. Use insert_id to get the primary key after inserting into the parent table.
Explore PHP file uploads: validate submission, check types, rename with time and randomness, create date-based folders, move files, and log destinations in MySQL.
Identify a cookie tampering vulnerability in image uploads and demonstrate fixing it by rechecking user identity before every operation and securing the upload process with a scanner.
Prevent duplicate image uploads by using a switch cookie during the upload process. If the switch is on, delete it and proceed; otherwise deny the upload.
learn to start a php session with session_start, avoid any output before it, and identify users via the session id stored in the php sess id cookie.
Start a session and store a value in the global session array under a password key, such as one two three four five six a b c.
Learn to completely delete a PHP session in three steps: clear the session array, delete the cookie with session_name, and destroy the server-side session with session_destroy.
Set and manage session expiry in PHP by using session set cookie or cookie-based expiry, including session name and session id, then test and reset sessions.
Learn to implement a fingerprint scanner using server-side sessions: rename login files, start a session, store username and password, verify the session, and log out by clearing data and cookies.
Explore PHP session management by starting sessions, storing username and password, validating login state, and securely logging out by destroying sessions and cookies.
Discover image processing with the GDI extension as a graphics card substitute, enable it in system settings, and use JPEG, PNG, GIF, WBMP with a canvas, brush, and ink.
Learn how to create a blank canvas with image create true color, specify width and height, handle the returned resource, and note GIF is not supported.
Explore creating ink colors with the image color allocate function in PHP, using red, green, and blue values to color a canvas and produce white or black.
Create a paint brush on a blank canvas using image fill, set a background color, and apply red ink at 0,0 to return true.
Output an image in PHP by using the image function with imagejpeg or imagepng, set the Content-Type header, optionally store the image in a database, and destroy the resource.
Learn to draw a dot, a straight line, and a rectangle in PHP using image set pixel, image line, and image rectangle, and display the resulting image in a browser.
Learn how to generate a verification code by drawing words onto a canvas with the image to text function, controlling size, angle, left bottom corner coordinates, color, font, and content.
Create a four-character verification code by building a source string of letters and digits (no special characters), then randomly pick four characters and concatenate them.
assemble the lessons to create a verification code image: build a canvas, allocate colors, add a border, sprinkle random pixels, and render four random characters.
Learn to implement verification codes on websites by saving the code to session, rendering it as an image, and performing case-insensitive checks with a dedicated string comparison function.
Watermark a picture using a logo or a text string, convert destination image into a canvas with image create from, and obtain width and height with imagesx and imagesy.
Learn how to watermark a picture with a website address by rendering a red, large-font string onto the image using precise coordinates, then output the watermarked image.
Overlay a logo as a watermark on a destination picture by converting the logo to a bitmap and using image copy with x, y, width, height to position it.
Learn to crop a picture with the image copy function by creating canvases, selecting a left top quarter using x, y, width and height, and pasting onto a new canvas.
Scale down a picture to a thumbnail using image copy resized or image copy sampled, then create a new canvas with the original’s width and height and fill it white.
Learn how four coordinates x, y, x2, and y2 control which part of an image is used for a thumbnail, and how zeroing them prevents blank areas.
The aim of this course is to help you master web development in the most efficient way.
The content design of this course is inspired by the Jiu Jitsu ranking system.
The whole course includes seven levels: yellow, orange, green, blue, purple, brown and black.
In yellow, orange and green course, considering you just started your PHP study, the learning curve is kept at a rather smooth level.
You will learn the most fundamental coding concepts and simple operations.
In blue belt, things start to change. The learning curve starts to get steep and you will need to combine skills learnt at different times together.
After purple belt, you will start to build programs that can be used in real-life situation. This means you will need to take into consideration safety and efficiency.
We know that everybody forgets. We also know that you have other things going on with your life and your study will be constantly interrupted. Therefore, every time previous knowledge is needed, we will give you a timely review. We believe this can make your study easier and more efficient.
Starting from purple belt, you will learn how to build program that can survive in real life. This means you need to learn more than just coding skills. You will learn program design and safety and efficiency knowledge.