Discussion – Lesson 7 - NOO-CMS - Displaying articles in PHP
BackComments
Member
6 messages from 6 displayed.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
Comments
You have admin permission in $_SESSION['user_admin']
, so use
something like this:
if (isset($_SESSION['user_admin']) && $_SESSION['user_admin'] == 1)
{
header('Location: admin-page.php');
exit();
}
else
{
header('Location: article.php');
exit();
}
still the code doesn't work
<?php
session_start();
require('Db.php');
Db::connect('127.0.0.1', 'noocms_db', 'root', '');
if (isset($_SESSION['user_id']))
{
header('Location: administration.php');
exit();
}
if ($_POST)
{
$user = Db::queryOne('
SELECT user_id, admin
FROM user
WHERE name=? AND password=SHA1(?)
', $_POST['name'], $_POST['password'] . "t&#ssdf54gh");
if (!$user) {
$notice = 'Invalid name or password.';
}else
{
$_SESSION['user_id'] = $user['user_id'];
$_SESSION['user_name'] = $_POST['name'];
if (isset($_SESSION['user_admin']) && $_SESSION['user_admin'] == 1)
{
header('Location: administration.php');
exit();
}
else
{
header('Location: reports.php');
exit();
}
}
}
?>
the admin an other users are taken to the reports.php page
Yes, sure. You removed setting permission for $_SESSION
. So
before if
with redirects add this:
$_SESSION['user_admin'] = $user['admin'];
Great tutorial, thank you.
6 messages from 6 displayed.