Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Arrays and Control Structures PHP Conditionals Operators

How do I correctly accomplish this task?

I am in the PHP Arrays and Control Structures section, and I am trying to correctly execute the task 1 of 1:

https://teamtreehouse.com/library/php-arrays-and-control-structures/php-conditionals/operators-2

Granted, I am having troubles with the system when pressing the "Check Work" button (I sent an email to help@teamtreehouse.com), but would like to see how this is accomplished,

index.php
<?php
$username = 'sketchings';
//Available roles: author, editor, admin
$role = 'editor';

//add conditional statement
if ($username) {
  elseif ($role != 'admin') {
            echo "You do not have access to this page. Please contact your administrator.";
    ]
}

3 Answers

I figured this out this morning:

if ($username && $role != 'admin') { echo "You do not have access to this page. Please contact your administrator."; }

Thank you James Jones for helping out as well.

<?php
if ($username && $role != 'admin') { 
  echo "You do not have access to this page. Please contact your administrator."; 
}
?>

Thanks for helping this worked for me as well

jamesjones21
jamesjones21
9,260 Points

<?php $username = 'sketchings'; //Available roles: author, editor, admin $role = 'editor';

//add conditional statement if(isset($username)){ echo "You do not have access to this page. Please contact your administrator."; }

That's how much I could do on my phone, but observing your code you need to take the angle bracket kit below the echo an replace with } otherwise it won't won't :)