PHP with PDO and OOP for beginners

Learn PHP with PDO, Object Oriented PHP programming, MySQL and Bootstrap to create powerful and secure websites and apps
4.4 (13 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.
213 students enrolled
25% off
Take This Course
  • Lectures 74
  • Length 6 hours
  • Skill Level All Levels
  • 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

PHP is one of the most popular programming languages. In this series, we will learn PHP programming basics, using a local server. Then we will use a PHP layer known as PHP data object PDO, to create secure and portable web applications. As a bonus, we will learn SQL and Bootstrap basics, to design databases, and create responsive platforms. At the end, we will create Object Oriented Programming functions and classes, and this section will help students to start their next step, which is learning a PHP framework. This course is meant for total beginners in any programming language. At the end of this course, you will be able to create databases, bootstrap designs, secure and responsive web applications with a strong login system.

What are the requirements?

  • Just a text editor

What am I going to get from this course?

  • Create Databases
  • Learn MySQL with PHP
  • Learn Basics of PHP Programming
  • Learn PDO with PHP to create secure web applications
  • Learn Object Oriented PHP Programming
  • Create advanced, well designed, responsive PHP and PDO based web applications
  • Learn Bootstrap
  • Create a powerful and secure login system
  • Learn Object Oriented Programming with PHP
  • Sessions and Cookies in PHP
  • And much much more

Who is the target audience?

  • This course is meant for newbies in PHP
  • This course is for developers who wants to learn PDO
  • This course is for PHP programmer who want to learn Object Oriented Programming
  • This course is for absolute beginners in 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: Installations and Workspace

PHP is one of the best programming languages used in web development and by almost thousands of websites like Facebook and Quora. It is a server-side language that recommends a server to execute PHP scripts. I recommend starting learning PHP language before PHP frameworks. The language itself will help us to figure out how to resolve errors and how to build and design our project.


In this course, we will need to work with a server like wamp for windows and mamp for Mac OS. And for databases, I recommend to download and install MySQL server with MySQL workbench. We are going to work locally using wamp.


We will encounter some errors while we are installing our local server, and we should close all softwares that run and test the port 80. This lecture will help to eliminate those startup errors that all PHP newbie will stuck in them for hours.


In this lecture, we are going to see the difference between server-side languages like PHP, Python, Ruby, and Java and client-side languages like JavaScript, HTML, and CSS.


In this lecture, we will learn how a communication occurs between a computer and database, using a layer used by PHP and called Database Abstraction Layer.


PDO is a lightweight interface, to access databases using PHP, and each database driver like MySQL, SQLite and Oracle should implement PDO interface. In this lecture we will learn about why PDO is more secure than other interfaces.


PHP is a server-side language. And to run .php extension files, and PHP scripts, those files should be installed in the local root of the server.


SQL injection is a way used by hackers to access and break web application using URL or the login form of a website. It is used by developer to test if their project is vulnerable and weak, and needs some improvements.

Section 2: PHP Basics

In this lecture, we will learn how to start typing PHP and what parts of a web page, the PHP interpreter execute using the PHP tags <?php ?> to identify it.


In this lecture, we learn how to print and echo results, and we will see the difference between them. We have a third function to print results: print_r() and we will use it later.


In this lecture, we will learn how PHP is different than other static languages and what types we can use in our PHP scripts. Usually we can define strings, integers, arrays, floats, doubles, and more.


In this lecture, we will learn how to make conditions into specific results and what is the value returned inside each condition.


In this lecture, we will see the difference between equality == and strict equality ===. Usually, equality will compare 2 variable values without caring about their types, and strict equality will compare variable types and values.


In this lecture, we will learn how to increment number using ++ and decrement them using - -.


There is a big difference between elseif and else if, when we are typing PHP scripts. We will take a simple example to understand it.


In this lecture, we will learn about while and do-while loops. The result will be the same, but syntax and slightly different.


In this lecture, we will learn about the other loop method in PHP, For and foreach. Usually we use foreach when we are iterating over an associative array.


Infinite loops are dangerous and may make harms to computers and our applications. We should be aware from making a false conditioning inside loops. Usually, infinite loops are used to make some test on a server, and they are scheduled.


From their names, break will help us to break a loop when a certain condition is true, while continue, will take us into next step of the loop when a specific condition is achieved.


Switch will help us to take specific values of a variables and set conditions and actions for each one of them. In this lecture, we take a simple example and see why and where we should use switch.


Goto will help us to skip some script lines, to execute another portion of the code, when a certain condition is true.


Basically, require_once() and include_once() will help us to add an external file into our page. But require_once() will stop executing any further PHP lines, if the file contain errors and display them. And include_once() will continue executing PHP lines but it will show us the error.


In this lecture, we will learn the and && and the or || operators, which help us to add more conditions inside a loop or an IF statement.


In this lecture, we will learn how to declare an indexed array, how to get array size, and how to use a loop to display all values.


Associative arrays are important when we work with AJAX and JSON. In this lecture, we will learn how to declare them, and display them on screen using foreach() loop.


In this lecture, we will learn how to declare and print multi-dimensional arrays.


They are multiple arrays premade functions to use while working with arrays. In this lecture we will learn how to merge, shift, and push arrays into other variables.


As other languages, we can work with math using PHP premade functions. In this lecture, we will learn some of them.


In this exercise we will calculate a factorial of a number and use a new function to test if a result is infinite or not.


In this exercise, we will create random arrays and fill them with random numbers, and create some discounts on the total sum.


In this exercise, we will take a premade script, and make iterations according to loops, and display the final results.

10 questions

In this quiz, we will make a recap, about all programming basics that we had seen in the previous sections.

Section 3: PHP and MySQL

In this lecture, we will learn how to enable error reporting while we are working offline, designing our web app, and how to set error reporting functions, when we put our work online.


In this lecture, we will see in details, each part of our connection strings, and what every single variable means.


In this lecture, we will learn how to design databases using MySQL workbench and PHPMyAdmin.


In this lecture, we will learn how to start working with bootstrap classes, to create responsive web applications and websites.


Servers only work with HTML name tags. So we should add name tags to each text box, and other HTML elements we have.


In this lecture, we will set up, the working space of our first landing page, which is the login page.


In this lecture, we will learn how to get data from HTML forms, into PHP server, using POST and Get methods. Then, we will walk through the difference between them.


In this lecture, we will learn how to use isset() and !isset() functions to see if a button is clicked, or a variable is set to a value.


MD5 isn’t a secure encryption method nowadays, to use it with passwords. We will use it for now, and in section 4, we will learn how to encrypt passwords using advanced crypto techniques.


In this lecture, we will type our first SQL query and use query() function to run it and get the results. This SQL query is without any parameters and when we use queries with variables, we should use another type of queries like prepare ().


In this lecture, we will see how to add parameters to SQL query, and why the PDO type is better than the old unsecure method where we were adding directly variables into queries and execute them, which get us into big security problems.


In this lecture, we will add our variables, into SQL query using bindValue() or bindParam(). And in this lecture, we will the difference between those 2 functions, but the both will help us to get the same result at the end.


In this lecture, we will learn how to execute queries using execute() functions, and fetch the result into a new variable using fetch() or fetchAll() functions. Then, we will learn how to check if a row exists in our database, using 2 methods.


In this lecture, we will create our first function. We have function that can take parameters, like the example in this lecture.

Section 4: Sessions and Cookies

In this lecture, we will see the difference between sessions and cookies, and we will start using sessions by checking if their already active one or not.


In this lecture, we will learn how to save user credentials in session. We will learn how to go to next page using header() function after a successful login.


In this lecture, we will create a global connection file and add it in all our pages, using require_once() function.


In this lecture, we will learn how to create a logout page, and destroy all our session using unset() and session_destroy() functions, and redirect into the login page.


In this lecture, we will learn how to create and set cookies, and specify their end-time using setcookie() and time() function.


In this lecture, we will improve password field, and add hashed strings instead of using MD5 encryption. Then, we will use password_verify() to see if a typed password would be the same as the hashed value in our database. This method will help us to increase our security level. At the end, we will learn about var_dump() function, that help us to get all information about a variable or a function.


In this lecture, we will learn about more super global variables like $_REQUEST and $_SERVER. We have $_FILES, $GLOBALS and more.

Section 5: AdminPanel Project

In this lecture, we will learn SQL query basics, from selecting a specific column, insert new data, updating existing information, delete rows, and create SQL views.


In this lecture, we will prepare our webpages and add some buttons, before we start programming and selecting data from database into our site.


In this lecture, we will see multiple types of returned arrays inside our fetch() and fetchAll() functions. And we will use fetchColumn() if we need to return a specific column of a table.


In this lecture, we will create an HTML table that will get all rows from login table, and we will add text boxes at the end, to add new users.  


In this lecture, we will create a delete button for each row we have in our table created in exercise 4.


In this lecture, we will create an update button to update user information.


In this lecture, we will learn how to get the last inserted ID into any table of our database, using a PHP function called lastInsertId(). We should know where to add this function and after which query, so we can get the correct id.


In this lecture, we will see 2 main types of errors. The first one is PHP error when we have syntax errors. And the second type is when we are handling with database, so it is called PDO Exception error.

Section 6: Object Oriented Programming in PHP

In this lecture, we will learn why we should use OOP in PHP, because it’s reusable, readable, and perfectly fit an advanced PHP based web application project. We will learn some new keywords like: object, class, method, property, and handler.


In this lecture, we will learn how to declare a class. A class is a blueprint of an object.


In this lecture, we will learn how to declare a new property for a class. And we will see different restrictions that we can use when we work with properties. Those restrictions can be used by the functions.


In this lecture, we will type our first method, and we will use a built-in variable called $this that refer to the current object, and help us to access a property or function in our class.


In this lecture, we will learn how to access a function a get a result from it. And we will learn the setter and getter method, where we make changes into a method, and we echo the result inside another method. 


In this lecture, we will learn how to include a class inside our web pages. Then, we will add a constructor method to our class, to initiate our properties. Construct method is automatically created when a class is executed.


In this lecture, we will solve exercise 6, where we are going to make changes on our procedural script and transform it into object oriented PHP script.


In this part, we will continue modifying our script, and run it when we click on the login button.


Inheritance in OOP is creating a new class that may use methods from another class. To do so, we use the ‘extends’ keyword for this. 


In this lecture we will solve the exercise 7, where we are going to change the insert procedural script into Object Oriented script.


In this lecture we will learn how to override an existing method of a parent class in the child class. And how to make restrictions on the methods and classes in the parent file.


In this lecture, we will learn about interfaces and abstract classes. The difference between them, and why we use them in our projects.


In this lecture, we will learn how to use a static keyword with a class, method, or a property, and why using static keyword will help us to reduce the amount of resources used, when executing a script.


A destructor method helps us to destruct the object created, when execution is done. Usually PHP will automatically create a destructor for each class, but there is no harm from typing a destructor method in each class.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Eng Ali Mehdy, Electrical and Telecommunications Engineer

I am an Electrical, Telecommunications and IT engineer graduate with a Master degree since 2013, with experience in designing software and web apps for telecommunication purposes, designing household electrical schematics and designing electrical panels. I have an advanced experience programming industrial microprocessors PLC. And now I am an Udemy Premium Instructor.

Ready to start learning?
Take This Course