Learn how to add code to all staff area pages to limit the access to the page to only logged-in admins.
- [Instructor] Now that we have the ability…for users to log in and log out…and we're able to remember in our session…whether or not they've logged in or not,…we're able to now add access control to our pages.…That is, that we can restrict the pages in our staff area…to only allow logged in users to see them.…The way we can do that…is just simply to go to one of our staff area pages…like index.php…and right here at the top,…we can just check to see.…Put php tags…and we'll just test to see if not dollar sign session…is logged in.…
Then I'm going to redirect…to url_for staff/login.php.…And if they're not for some reason,…then let's just do nothing,…let the rest of the page proceed.…So that's it, that's the process.…It's going to check and see if the session says…that the user is logged in.…
If they're not, then it will redirect them.…If so, then they'll do nothing.…Let's save it and try it out.…Now at the moment, I am logged in.…Let's reload our page here on index.php.…Yup, I am still logged in.…If I click logout, now I'm not logged in.…
Note: This is an intermediate-level training course that assumes you have existing knowledge of PHP. To refresh your skills, check out PHP Essential Training and PHP: Object-Oriented Programming.
- Creating a project database and tables
- Connecting to the database
- Database queries with OOP
- The active record design pattern
- Defining a database-driven class
- Performing common database tasks with OOP
- Creating inheritable and reusable code
- Object-oriented user authentication
- Object-oriented pagination
Skill Level Intermediate
Consuming RESTful APIs in PHP with Guzzlewith Justin Yost2h 12m Intermediate
PHP: Accessing Databases with PDO and MySQLiwith David Powers3h 47m Intermediate
1. Overview and Project Setup
2. The Database Connection
3. Define a Database-Driven Class
4. Object-Oriented CRUD
5. Object-Oriented Authentication
6. Object-Oriented Pagination
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.