commit f645cb6b89a2ad954019c5c5dc4433cd4a9b4075
parent c5f4e422b593ac50732ca08956e2121721164a07
Author: MoiBaguette <[email protected]>
Date: Wed, 12 Apr 2023 16:07:31 +0200
debugs
Diffstat:
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/crud_user.php b/crud_user.php
@@ -6,10 +6,15 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
</head>
<?php
+ include "navbar.php";
include 'utils/autoloader.php';
- if(!in_array(1, $_SESSION['permissions'])){
- header('Location: dashboard.php');
- exit;
+
+ $permissions = $_SESSION['permissions'];
+ if(!isset($_SESSION['email'])){
+ if(!in_array(0, $permissions)){
+ header('Location: dashboard.php');
+ exit;
+ }
}
?>
<body>
@@ -51,6 +56,7 @@
</div>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
+
$errors = array(); // initialize an empty array to store errors
// Check if voornaam is set and not empty
@@ -109,11 +115,11 @@
$bool = $u->insert();
if(!$bool){
echo "user already exists";
+ }else{
+ echo"succes!";
}
}
}
- // closing the connection
- mysqli_close($conn);
?>
</body>
</html>
diff --git a/navbar.php b/navbar.php
@@ -7,6 +7,13 @@
// Get the permission level of the user
$permission_levels= $_SESSION['permissions'];
+ if ($_SERVER["REQUEST_METHOD"] == "POST") {
+ if(isset($_POST['logout'])) {
+ echo "This is Button1 that is selected";
+ session_abort();
+ header('Location: login.php');
+ }
+ }
// Assume $permission_levels is an array containing the user's permission levels
$links = array();
@@ -71,6 +78,10 @@
</li>
<?php } ?>
</ul>
+ <form method="post">
+ <input type="submit" name="logout"
+ class="button" value="Logout" />
+ </form>
</div>
</nav>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>