Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There seems to be quite a few things to fix, here are a few:</p> <pre><code>//the if statement will only be entered if sessionloginid is set, only set inside the statement, which will never be entered if(isset($_SESSION['sessionloginid'])) { //you should use prepared statements. Query will never run here, since the sessionloginid is never set. $query ="SELECT * FROM privilege where login_id='".$_SESSION['sessionloginid']."'" ; //your login_id used above is not unique. It should be a key, and autoincremented $result = mysqli_query($link,$query) or die(''); //since login_id is not unique, this while loop will replace the session variables you will set with the last row returned. while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { //storing access level, but never used again $access = $row['AccessLevel']; //the following two lines don't do anything $_SESSION['sessionloginid']; $_SESSION['sessionaccess']; //Example replacement: $_SESSION['sessionloginid'] = $row['login_id']; } } </code></pre> <p>Next issues:</p> <pre><code>function login() { //this function will return true or false, but does not set or do anything. Intentional? return (isset($_SESSION['sessionloginid'])) ? true:false ; //this echo will not run, since the function stops on return echo $_SESSION['sessionloginid']; } //calling login here does nothing, since login only returns a Boolean value. login(); </code></pre> <p>The protection will never run header() since the sessionloginid is never set to true, and session access is never set as well.</p> <pre><code>function protect_page(){ //sessionloginid is never set, so will never be true if($_SESSION['sessionloginid']== true &amp;&amp; $_SESSION['sessionaccess'] !=1 ){ header ('location:http://localhost/database/agtdatabase/agt_site/agtSite/agt2.php'); //echo $_SESSION['sessionaccess']; output 12 when user a logged in exit(); } } </code></pre> <p>I realize this doesn't completely answer the question, but it should get you headed in the right direction, I hope. Fix those, and let me know what you get. Side note: login_id should be table key, I would think. It should be autoincremented and unique. Otherwise you could get multiple results, instead of a unique user logging in. For example, a login_id of 1 could grant access level of 1 or 2, since there is a login_id of 1 for each of those access levels.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload