Hi,
I am having trouble with this code and would like to see if anyone can help me.
I have been trying to write a bit of code that would check in the database if the users role is either admin or something else. and then allow them to view the page or show a message stating "they are not the admin"
Heres is the code.
<?php
require("head.php");
include("navbar.php");
require("common.php");
{
$query = "
SELECT
id,
username,
password,
salt,
email,
role
FROM users
WHERE
username = :username
";
$query_params = array(
'role' => $_POST['role']
);
$row = $stmt->fetch();
$_SESSION['role'] = $row;
if($_SESSION["role"]=='admin'){
echo "<h1 class='container well'>YOU ARE IN!</h1>";
} else {
echo "<h1 class='container well'>you need the admin role!!!!</h1>";
}
}
include("footer.php");
?>
I think I have mucked this up completely and might be writing the wrong thing? or I am missing a big chunk.
Any help would be much appreciated.