From the course: PHP: Object-Oriented Programming with Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Admin class

Admin class - PHP Tutorial

From the course: PHP: Object-Oriented Programming with Databases

Start my 1-month free trial

Admin class

- [Instructor] In this chapter, we will add user authentication to the staff area of our project. We discussed user authentication in the PHP with MySQL Essential Training course, so we won't revisit all of the fundamental concepts. However, we will learn to use object-oriented programming techniques instead of the procedural programming that we learned before. The first step is to create our admin class. To do that, we'll first need to create a database table to store our admins, so I'm going to call that admins and it's going to have a number of columns on it. Obviously, it will need an ID column for its primary key, but we'll also have first_name, last_name, email, username, and hashed_password as columns. The hashed_password will store an encrypted version of the password. Once we have database table defined, then we can define our admin class, being sure to inherit behavior from the DatabaseObject class so that we have all of the active record behavior we created in the last…

Contents