I'm trying to check if a user is a regular user or an admin.
In my database, the last item is "usertype" and it is a 0 or 1.
0 for regular user and 1 for admin user.
For some reason this is not working. It always tells me I am a "regular user." Which I know cannot be true. I did set usertype as an int to 1.
Here is my admin.php page
<?php
include_once '../includes/db_connect.php';
include_once '../includes/functions.php';
sec_session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Dashboard</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<?php
// Create connection
$con = mysqli_connect(HOST, USER, PASSWORD, DATABASE);
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM members");
$row = mysqli_fetch_row($result);
?>
<?php
if ($row["usertype"] == 1)
{
echo "You're an admin!";
}
else
{
echo "You're a regular user.";
}
?>
</body>
</html>