From the course: PHP with MySQL Essential Training: 2 Build a CMS

Unlock the full course today

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

Authenticate user access

Authenticate user access

- [Instructor] In this movie, we'll learn to authenticate user access. In other words, we'll write the code that will allow a user to log in with a username and a password. Before we dive in and look at the code, I'm going to add a new file. It's in the exercise files, it's called auth_functions.php, and I'm going to put it in my private directory. This is a place where I'm going to store all of the functions related to authorizing a user. It'll just keep them separate from everything else. So let's go in to our code, and the first thing I need to do is go to initialize.php. And make sure that the authorization functions are also required. Let's just add that right here. Auth_functions.php. Okay, so now that I have my authorization functions, let's take a look at what's in them. You see I have simply one function here called log_in_admin. And when I pass it in, an associative array for the admin, this admin object that we're working with, it's going to take care of all the business…

Contents