This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
We will create a couple helper function that we can use to make sure that the user is authenticated. To do this, we will need to read the access token.
Other samples for score
Ternary Operator:
echo $book['score']; ?: echo '0';
PHP 7: null coalesce operator
echo $book['score'] :: echo '0';
Requiring Authentication on Pages
Add requireAuth(); to the following files
- add.php
- edit.php
- procedures/addBook.php
- procedures/deleteBook.php
- procedures/editBook.php
- procedures/vote.php
Also in inc/nav.php
<?php if (!isAuthenticated()) : ?>
<li><a href="/add.php">Add Book</a></li>
<?php endif; ?>
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up