Learn By Example: PHP For Dynamic Websites

Super-practical PHP: cookies, sessions, login authentication, MySQL integration, Object Oriented PHP and lots more!
4.8 (4 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
112 students enrolled
70% off
Take This Course
  • Lectures 77
  • Length 13 hours
  • Skill Level Beginner Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 4/2016 English

Course Description

Super-practical PHP: Learn, by example, how to build a smart website with cookies, sessions, login authentication, MySQL integration, Object Oriented PHP and lots more!

Let's parse that.

  • This course is super-practical: packed with knowledge you can put to use right away, while still giving you a good foundational understanding of web programming, not just PHP.
  • Its about building smart websites: these days, its not OK for a website just to look snappy - login, cookies and  sessions are considered necessities, not luxuries anymore
  • In this course, we will learn by example. Each example is self-contained, has its source code attached, and gets across a specific PHP use-case. Each example is simple by itself, but they come together as building blocks to build complex use cases.

What's included in this course:

  • Installing and setting up a basic web server with PHP
  • Web security basics: validating and sanitizing user input data. Web forms, mitigating XSS and XSRF attacks
  • MySQL Integration and Installation: Connecting to a database, running queries, processing results, prepared statements. Easy integration with MySQL so it's dead simple to work with databases for permanent data storage
  • Cookies, Sessions and the differences between them, using sessions without cookies
  • End to end login authentication
  • Object oriented PHP, classes, inheritance, polymorphism
  • GET, POST and other superglobals

Talk to us!

  • Mail us about anything - anything! - and we will always reply :-)

What are the requirements?

  • No prior programming experience needed, this course starts at zero
  • A little basic HTML, CSS and SQL will be helpful for some of the examples - not really required though!

What am I going to get from this course?

  • Apply advanced constructs such as cookies, sessions and object oriented programming correctly
  • Mitigate basic web security risks by sanitizing and validating user input
  • Build a robust login authentication system using MySQL to allow users to sign up and log into your site
  • Harness the power of programming to build intelligent, interactive and personalized web sites

Who is the target audience?

  • YEP! Students who are looking to use the power of programming to build dynamic web sites
  • YEP! Students who are looking to get into the nitty gritty of advanced PHP constructs such as cookies, sessions and object oriented programming

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: You, This Course, and Us!

What is this course? How will it help you? What will you learn if you take this course and finally who can take this course. All these answered:-)

Section 2: Installing and setting up PHP

PHP is a programming language which runs on the server, makes decisions, edits HTML to reflect those decisions and transmits pure HTML to the user. PHP has powerful constructs to work with web sites and abstracts away a lot of the nitty gritty!


If you have a Windows machine follow the instructions in this lecture to get up and running with Apache server and PHP!


If you have a MAC machine follow instructions in this class to get started with PHP. Apache comes pre-installed on a MAC you just have to enable PHP and you're ready to go!

Section 3: Basic Constructs In The PHP Language

The PHP equivalent of "Hello World", more like "Yay, PHP you work!"


The output of a PHP program is pure HTML and CSS which is sent down to the client browser. PHP is a server side language which means all the intelligence lies on the server.


Variables are containers which hold values, the values in a variable can change during the course of the program i.e. the values "vary".


Variables can be strings, integers, doubles, booleans - these are the primitive types which form the building blocks of any language


Making decisions is a key to an intelligent site. The if-else and the switch statements are core decision making constructs present in all modern programming languages.


Strings are just a sequence of characters, learn the details of how to work with strings so you don't get tripped up


Combine conditions using "and", "or" and "not". 


Web forms are used to get user input which can be processed and stored on a site. Forms integrate seamlessly with PHP.


There are 2 ways to send requests to the server. The GET uses visible URL parameters and gives rise to bookmarkable and cacheable pages.


The POST on the other hand uses the request body to send user data. It accepts more data types and is the preferred way to send user input data to the server.

Section 4: Web Forms, Validating And Sanitizing User Input, Mitigating Security Risks

Accessing and processing input data on the server


Superglobals are predefined variables which can be accessed everywhere in PHP. They're very useful because they abstract away all the details of how the data was made available and they're super easy to use!


Submitting a form can open a tiny door to cross site scripting attacks. The htmlspecialchars() function helps you mitigate such risks.


User input is always malicious. Sanitize user input data to ensure that it does not mess with your website! Sanitizing data involves removing all potentially scary stuff from the input.


User input is always malicious. Validate user input data to ensure that it looks like how you want it to! Validating input data involves rejecting all input which has potentially scary stuff in it.


Accept input in a web form, sanitize it, validate it, show errors and then finally accept it!


Getting your local machine to act as a mail server requires some set up. Configure your machine to send email using a Gmail account.


Getting your local machine to act as a mail server requires some set up. Configure your machine to send email using a Gmail account.


After all the set up writing code to send email is extremely straightforward!

Section 5: Intermediate Constructs In The PHP Language
Example 13 : Introduction to arrays

Associative arrays in PHP are also called Maps or Dictionaries in other programming languages


Arrays can have any number of dimensions and each dimension can be a normal array or an associative array.


Loops are a way to do things over and over and over again till you ask it to stop!


Break allows you to break out a loop early and continue allows you to skip certain iterations.


Functions are a way to name a logical unit of code and call it to do stuff for you.

Example 29 continued: Blueprints and houses, classes and objects
Example 15 : Pass by Value, Pass By Reference, Default Values

All about local and global variables and where in code you can see and access variables.


Global variables need a special keyword to work and static variables remember their values across function calls.

Section 6: PHP and MySQL - A Well Oiled Integration

MySQL is a great database to use with your websites. And it's free!


Enabling MySQL for Windows is so simple it takes all of 23 seconds:-) Set up a new user and password to access the database, create tables etc from your PHP script.


Download and install MySQL for the MAC


Set up a user name and password to connect to MySQL and use the MySQL Workbench, a user interface, to manage the database


One last bit to do before PHP can talk to MySQL

Example 17 : Connecting, Running Queries, Closing a Connection

Make your database useful. Create a table and insert stuff into that you can use later.

Example 19 : Running select queries

Prepared statements allow you to specify a framework for your SQL query and then plug in specific values - very useful when data comes in via user input.

Section 7: Cookies And Sessions - Stuff Which Makes PHP Cool

Cookies are little bits of information stored on your machine which allow web sites to remember you even when you're not logged in.


Working with cookies in PHP is dead easy - use superglobals and simple functions to set, access and delete cookies. 

Example 21 : Deleting a cookie

Sessions remember stuff about a user for a predetermined period of time and store information on the server! This means it can also be used to store potentially sensitive information.


PHP makes using sessions very easy indeed, once again with superglobals and built in functions.

Example 22 : Destroying sessions

All pages of your website use the same session. Session id is generally communicated to the client via a cookie which is sent to the server on every request but sessions can work even when cookies are turned off! Learn about the session.use_trans_sid flag which makes this easier.

This is a common interview question for PHP developers.


Write code which can use sessions even when cookies are turned off.

Section 8: Build A Login Authentication System From The Ground Up
Steps to build a login authentication system

All source code need not sit in one file. Break up your code into logical components in different files and include those files when you want to use that code.

Ohh and while you learn this set up a Users table which will hold all users that sign up for your site.


When users sign up they should be added to the Users table so you have a permanent record. While storing passwords in a database make sure you encrypt them, otherwise it's a huge security risk.


While sending data from the client in the sign up form we need a way to ensure that only our trusted site is allowed to sign up new users. Use session variables to make sure this is the case.


Once a user signs up he can login, compare the logged in user against the list of users in your database.


Redirecting the user to a login success page involves emitting a special header. Unfortunately there are a lot of details to work around to get this working.


Once a user logs in the web site should remember the user till as long as the session lasts. Also if the user originally requested a certain web page she should be redirected to that page one she logs in. This lectures puts together all these fine touches.

Example 28 : Logout
Section 9: Advanced Constructs in PHP: Object Oriented Programming

Classes and objects allow us to model the real world in programming. This helps bring the basic data types together as building blocks into more meaningful and logical units.


Get introduced to your first PHP class. Lot's of terms here but these are all the lingo of object oriented programming so it's helpful to understand what they all mean


The constructor and destructor are special member functions of a class that are called automatically while creating an object and when destroying and object. 


These access types determine which code can access members of a class. Some class internals you might want to keep private and others are meant for outside code to access. These allow you to make these restrictions explicit.


A dog is an animal but a pug is very different from a doberman. The use of inheritance with classes allow such relationships to be modeled as well!

Example 32 : Working with base and derived classes

Inheritance gives rise to a new category of code - the code in derived classes. This gives rise to a new access type which allows code in derived classes to access certain base class members.


An object knows itself and knows what members to access within itself. This complicated concept will seem much simpler when you watch this lecture!

Example 35 : Final and abstract

Static variables are shared across all objects of a class - a complete about face from how other member variables behave.


pi is a constant, don't hardcode it's value or use variables to represent it!


Interfaces are constructs which are used to specify the behavior of a class but not how that behavior is achieved.

Section 10: Some random useful stuff

Filters can both sanitize and validate data - they're capable of some pretty cool stuff


A brief introduction to common headers and what they mean

Section 11: Working with files
Example 41 : Read and file and display it's contents

Get the name of the file, file size etc

Example 43 : More flexibility with files fopen(), fread() and fclose()

You can completely overwrite the contents of an existing file or append to it. Make sure you know the difference.


Upload a file to the server, check for errors, check whether it's the correct type and then finally save it on your server.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Loony Corn, A 4-person team;ex-Google; Stanford, IIM Ahmedabad, IIT

Loonycorn is us, Janani Ravi, Vitthal Srinivasan, Swetha Kolalapudi and Navdeep Singh. Between the four of us, we have studied at Stanford, IIM Ahmedabad, the IITs and have spent years (decades, actually) working in tech, in the Bay Area, New York, Singapore and Bangalore.

Janani: 7 years at Google (New York, Singapore); Studied at Stanford; also worked at Flipkart and Microsoft

Vitthal: Also Google (Singapore) and studied at Stanford; Flipkart, Credit Suisse and INSEAD too

Swetha: Early Flipkart employee, IIM Ahmedabad and IIT Madras alum

Navdeep: longtime Flipkart employee too, and IIT Guwahati alum

We think we might have hit upon a neat way of teaching complicated tech courses in a funny, practical, engaging way, which is why we are so excited to be here on Udemy!

We hope you will try our offerings, and think you'll like them :-)

Ready to start learning?
Take This Course