Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting permissions in PHP
    text
    copied!<p>I have a table called <code>admin_permissions</code> with the following columns:</p> <ol> <li>sequence</li> <li>page_name</li> <li>level_user</li> <li>level_admin</li> <li>level_support</li> <li>level_accounts</li> </ol> <p>the last 4 columns are the different levels</p> <p>I have this code which checks the permissions:</p> <pre><code>$permission_sql="SELECT * from admin_permissions where page_name = '".$_SERVER["REQUEST_URI"]."' "; $permission_rs=mysql_query($permission_sql,$conn); if(mysql_num_rows($permission_rs) == 0) { echo '&lt;h2 align="center"&gt;An Error has occurred!&lt;/h2&gt;'; exit(); } else { $permission_result=mysql_fetch_array($permission_rs); if($usertype_user != $permission_result["level_user"] or $usertype_support != $permission_result["level_support"] or $usertype_admin != $permission_result["level_admin"] or $usertype_accounts != $permission_result["level_accounts"]) { echo '&lt;h2 align="center"&gt;Access Denied&lt;/h2&gt;'; echo '&lt;h2 align="center"&gt;Please contact your administrator quoting \'Permission Error\' and number \''.$permission_result["sequence"].'\'&lt;/h2&gt;'; exit(); } else { } } </code></pre> <p>the <code>$usertype_</code>... either equal '' or 'yes' and the database results either equal '' or 'yes'</p> <p>the user i am logged in as, has <code>$permission_result["level_admin"]</code> equal to yes so the above if statement should be false but its not, its saying its true</p> <p>how can i get the above code to work</p> <p>*<em>P.S. I am not worried about SQL Injection on this particular code</em></p>
 

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