Jump to content

[SOLVED] Multi level log in


gavin1512

Recommended Posts

Good Day,

 

I am currently working on an internal order system for my Dissertation project and having problem locating some code for a multi level log in system, my system has four levels of log in and each will require a different home page, any help would be much appreciated.

 

Thank You  ;D

Gavin

Link to comment
https://forums.phpfreaks.com/topic/84302-solved-multi-level-log-in/
Share on other sites

try somthing like this if you already have a levels column in your table for user level

 

switch ($row['level']) {
case 0:
    header('level0.php');
    break;
case 1:
    header('level1.php');
    break;
case 2:
    header('level2.php');
    break;
}

 

Hope that this is of use to you.

 

Regards

Liam

Thanks Liam,

 

That is what I need, not being to great with PHP and mySQL before I spend ages playing about can I just check something...

does this line "switch ($row['level']) {" refer to the row in the database? in my case this is access. In mySQL access is either user, manager, approver or administrator, how do I apply these scenarios in to the case?

 

thank you for your help hope you are having a good day.

still have an issue due to my inexperience with PHP and not having used it for 2 years, I tired embedding the case statement in my If statement for checking username and password, below is my code:

 

<?php

session_start();

require "connect.php";

$username = $_GET['username'];

$password = $_GET['password'];

$query = "select * from employee where username = '".$username."' and password = '".$password."'";

$result = mysql_query($query, $connection)

or die ("Unable to perform query<br>$query");

$row= mysql_fetch_array($result);

if ($row != null)

{

$_SESSION['username'] = $row['username'];

 

switch ($row['access']) {

case 'user':

    header('user home.php');

    break;

 

  case 'manager':

    header('manager home.php');

    break;

 

    case 'approver':

    header('approver home.php');

    break;

 

    case 'admin':

    header('admin home.php');

    break;

}

exit();

}

else

{

$message = "Invalid username or password, please try again";

header("Location: home.php? message=$message");

exit();

}

?>

 

If some one could set me straight on where best to put it I will be very relieved lol

in my SQL database the field is stored as admin, originally before the case break statement it would just point at user home.php, but now i have tried all four levels of log in and no page loads and no error message is displayed. The page it tries to load is http://localhost/logincheck.php?username=abowell&password=liverpool&submit=Login and not the actual page relevant to the level of log in.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.