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

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Admin class

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