I'm trying to create login system with Permissions. I want to know how I check for the level of the user, If it's an Admin, Technician etc... I've made a simple login with a user.
This is my index.php (Form)
<html>
<head>
<title>Log-In</title>
<meta charset="UTF-8">
<meta name="author" content="Augusto Mendes">
<meta name="description" content="All">
<link rel="stylesheet" href="styles.css">
</head>
<body id="Both">
<form id="login" name="form" method="POST" action="/site/base/login_config.php">
<div class="form">
<label>Username</label>
<input type="text" name="username">
</div>
<div class="form">
<label>Password</label>
<input type="password" name="password">
</div>
<div class="form">
<input type="submit" value="Submit">
</div>
</form>
</body>
This is my login_config.php (Login verfication)
<?php
//Gets the Form's Variavels
$user = $_POST["username"];
$pass = $_POST["password"];
//Import "config.php"
include("config.php");
//Check the Data on the Database
$sql = "SELECT * FROM users WHERE User = '$user' AND Password = '$pass'";
$result = mysqli_query($connect, $sql);
$nreg = mysqli_num_rows($result);
if($nreg > 0){ //Check if any of the registries exist - If user exists
$reg = mysqli_fetch_array($result);
session_start();
$_SESSION["User"] = $reg["User"];
echo "Welcome ".$_SESSION['User'];
//header('Location:../index.php');
//I want this to redirect for User or Admin pages with their permissions
}
else{
//header('Location:../wrong.html');
}
?>
This is my config.php (Connection and database)
<?php
// Server COSNTs (Server, User, PW, DB)
define('SERVER', 'localhost');
define('USERNAME', 'root');
define('PASSWORD', '');
define('DATABASE', 'loja');
$connect = mysqli_connect(SERVER, USERNAME, PASSWORD);
// Connection to the MySQL Server
if (!$connect){
echo " Error: Connection to the Server FAILED! ";
echo "<script type='text/javascript'>alert(' Error: Connection to the Server FAILED! ')</script>";
exit;
}
$choose = mysqli_select_db($connect, DATABASE);
// Connection to the Database
if (!$choose){
echo " Error: Connection to the Database FAILED! ";
echo "<script type='text/javascript'>alert(' Connection to the Database FAILED! ')</script>";
exit;
}
?>
0: Windows Technician 1: Apple Technician 2: Store Manager 3: Admin 4: N/D right now
Since i've 2 folders one for users (0, 1, 2) and admin (3) i wanted to make only permissions per users. Admin has access to Users' Data but not their folders and Users can't go to Admins.
Thanks for reading. -Ryan