add authentication

This commit is contained in:
Hendrik
2017-01-26 13:29:56 +01:00
parent b89a575039
commit 1a53d01747
3 changed files with 24 additions and 0 deletions

View File

@@ -12,6 +12,14 @@
* This view adds the main layout over the screen.
* Header and menu.
*/
include_once ("../queries/user.php");
$userinfo = getRoleByID($_SESSION['userID'])->fetch(PDO::FETCH_ASSOC);
if ($userinfo['role'] != 'admin' AND $userinfo['role'] != 'owner') {
header("location:profile.php");
}
include("../views/main.php");
/* Add your view files here. */

View File

@@ -370,3 +370,18 @@ function countSomeUsers($search) {
$q->execute();
return $q;
}
function getRoleByID($userID) {
$stmt = $GLOBALS['db']->prepare("
SELECT
`role`
FROM
`user`
WHERE
`userID` = :userID
");
$stmt->bindParam(':userID', $userID);
$stmt->execute();
return $stmt;
}

View File

@@ -2,6 +2,7 @@
<?php
require_once ("../queries/user.php");
require_once ("../queries/group_page.php");
?>
<!-- function test_input taken from http://www.w3schools.com/php/php_form_validation.asp -->
<?php