Note that there are some explanatory texts on larger screens.

plurals
  1. POPage protection does not work correctly for the Administrator page
    text
    copied!<blockquote> <p>I posted a similar post of this whith a different code, but changed it a little now, and did not get an answers that I was hoping for (the answers did not help me much). I hope this is Ok, tell me if it is not. :)</p> </blockquote> <p>I have been trying to make a page protection for the Administrator page, and I can not get it to work. I am sure this would not have been a problem if I was not new to PHP coding, hehe.</p> <p>When a normal user with the type '0' is trying to access the administrator page, <strong>index_admin.php</strong>, the user will get redirected to the normal user page, <strong>index.php</strong>. And if the user have the type '1', then the user/admin will stay on the page.</p> <p>Here is the code I have been trying to get working. (This file is required in <strong>index_admin.php</strong> and it is called <strong>index_admin_check.php</strong>).</p> <p><strong>index_admin_check.php</strong> :</p> <pre><code>&lt;?php session_start(); ?&gt; &lt;?php $vert = "localhost"; $brukarnamn = "root"; $passord = ""; $db_namn = "nettsidebunad"; $tbl_namn = "kunde_register"; // Connection to the MySQL database. mysql_connect("$vert", "$brukarnamn", "$passord") or die ("Kan dessverre ikkje koble til databasen."); mysql_select_db("$db_namn") or die ("Kan ikkje finna den ynkjande databasen."); ?&gt; &lt;?php if (isset($_SESSION['mittbrukarnamn'])) { $sql1 = "SELECT `type` FROM $tbl_namn"; $rad1 = mysql_query($sql1); $type1 = mysql_fetch_row($rad1); if ($type1 == 0) { echo "You do not have access to this page."; //header("location: index.php"); } else { echo "You have access to this page."; } } ?&gt; </code></pre> <p><strong>Some of this text is in norwegian.</strong></p> <blockquote> <p><em>$vert</em> = $host (in english)</p> <p><em>$brukarnamn</em> = $usernamn (in english)</p> <p><em>$passord</em> = $password (in english)</p> <p>$db_<em>namn</em> = $db_name (in english)</p> <p>$tbl_<em>namn</em> = $tbl_name (in english)</p> <p>$_SESSION[<em>'mittbrukarnamn'</em>] = $_SESSION['myusername'] (in english)</p> </blockquote>
 

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