In functions.php you already have a function which checks if the user is logged in using cookies.  Edit that:

  1. delete everything inside the if and everything inside the else
  2. inside the if set a variable $type to not logged in
  3. inside the else add a line which gets the type from $_SESSION and saves it in the variable $type
  4. between the else closing curly bracket and the function closing curly bracket put a new line
  5. on the new line put return $type; to send the value back to the pages which call this function

Using the logged in check

  1. near the top of viewlog.php you should have two lines which include functions.php and call the function which checks if the user is logged in
  2. at the beginning of the line which calls the function add $type= (that variable will receive the value returned from the function you just created)
  3. under that add the first line of an if statement: if($type=="admin"){
  4. just under the echo of the table closing tag add a new line
  5. on that new line put the closing curly bracket for the if you just added
  6. it is worth commenting that closing bracket so you know what it closes next time you look

Now when you try viewlog.php in a browser you should see nothing except the footer if you are not logged in.  Log in as Samaira and you should still see nothing.  Log in as Pandora and you should see the log.

This is a bit messy/ugly and you might want to improve it later but it does protect the data.  Adding an else with an explanation and a link to the log in page would be one approach.