No idea how to write this PHP statement pls help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

No idea how to write this PHP statement pls help

If session role not "superuser" and "admin" then redirect

31st Dec 2020, 11:39 AM
Sandy Harys
Sandy Harys - avatar
1 Answer
0
You need to assign the session role to variable e.g $role or get the user role from the database with SELECT statement. PS. For test you can specify role before the if code: This is one of the examples $role = 'admin'; // change to user and you should see a message with no access. if($role != 'superuser' && $role != 'admin') { echo 'You have no access to this page!'; } else { echo 'Hello '.$role.'.'; // your code }
31st Dec 2020, 1:02 PM
speedprogame
speedprogame - avatar