When a user login, he/she will be directed to the page based on his/her user type… I’ve already accomplished that.
Now, how to make the page recognize the user_id(auto-increment from user table) so that i can post some of the user information and so on?
function.php
[CODE]<?php
function checkUserType($type)
{
switch($type)
{
case ‘admin’:
$page = ‘admin.php’;
break;
case 'student':
$page = 'student.php';
break;
case 'lecturer':
$page = 'lecturer.php';
break;
case 'parents':
$page = 'parents.php';
break;
}
header('Location: '.$page); //You may need to edit the path to suit your folder structure.
exit();
}
function checkUserStatus($actual_page)
{
//First check to make sure the $_SESSION[‘type’] is set, if it’s not then they haven’t logged in so redirect back to login screen
if(!isset($_SESSION[‘type’]))
{ header(‘Location: index.php’); }
else
{
if($actual_page == $_SESSION[‘type’]){}
else{ checkUserType($_SESSION[‘type’]); }
}
}
?>[/CODE]
index.php (login page)
[CODE]<?php session_start(); ?>
Login FormMember Login |