I am having trouble making a PHP code. The PHP code a header navigation. In this header, It will show different headers for different users. I had added a column in my SQL database called "groups". I had added the default "0" as a INT. So when users make an account, It sets the "groups" to value 0.
In my admin panel, I have a table where you can edit the value on the groups. Users value is "0" and Admins value is "1"
The part I am stuck on is actually making the code to work. I tried to research on my issue but I could not find any solution.
Here is the code:
<?php
include('authCheck.php');
include('dbCredentials.php');
$group = isset($_GET['group']);
// Query
$sql = "SELECT * FROM AccountInfo WHERE group = :group";
$cmd = $conn->prepare($sql);
$cmd->bindParam(':group', $group, PDO::PARAM_INT);
// Run query
$cmd->execute();
$groups = $cmd->fetch(PDO::FETCH_ASSOC);
if ($groups['group'] < 0) {
echo '<li><a href="#">Home</a> </li>
<li><a href="#">Edit List</a> </li>
<li><a href="#">Logout</a> </li>';
} else if ($groups['group'] < 1) {
echo '<li><a href="#">Admin Panel</a> </li>
<li><a href="#">Home</a> </li>
<li><a href="#">Logoff</a> </li>';
} else {
echo '<li><a href="login.php">Login</a> </li>
<li><a href="register.php">SignUp</a> </li>';
}
?>
Please help, thank you! :)
EDIT
Here is the SQL DB
CREATE TABLE AccountInfo
(
user_id INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
email VARCHAR(50),
password CHAR(128),
group INT(2) DEFAULT '0'
);
The USER_ID is used to identify each user by ID.