Note that there are some explanatory texts on larger screens.

plurals
  1. POPage protection for the Admin page not working
    text
    copied!<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>So what I am trying to do is, 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>So 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> <pre><code>&lt;?php session_start(); ?&gt; &lt;?php $vert = "localhost"; $brukarnamn = "root"; $passord = ""; $db_namn = "nettsidebunad"; $tbl_namn = "kunde_register"; // Connecting 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 // *** Page protection *** \\ // Admin check. If `type` = 1, let the user (admin) stay on the site. If `type` = 0 kick the user (normal) off the site. $sql = "SELECT `type` FROM $tbl_namn"; $res = mysql_query($sql); $tell = mysql_num_rows($res); if ($tell == 0) { header ("location: index.php"); exit(); } ?&gt; </code></pre> <p>Some of this text is in norwegian.</p> <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><em>$db</em>_namn = $db_name (in english)</p> <p><em>$tbl</em>_namn = $tbl_name (in english)</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