Help with Account Levels in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pilsy2001
Forum Newbie
Posts: 16
Joined: Tue Jun 20, 2006 8:00 pm

Help with Account Levels in PHP

Post by pilsy2001 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi Guys,

I am working on a Heavily modified OsCommerce MS2.2.2 Distribution...

at the moment i am trying to make a contribution that will allow users to display different infobox's for different account_level types, for instance franchise level is displayed franchise tools menu, wholesale has the wholesale tools menu etc...

I have some of the code ready to go and was wondering if anyone (Everah you sexc beast) could help me 
[b][Filename: accountselect.php][/b]

Code: Select all

if(isset($customers_id))
	{
		$sql = "SELECT account_level, customers_id FROM `customers` WHERE customers_id = '$customers_id'";
		if(!$result = mysql_query($sql))
		{
				die('Could not connect to the Database' . mysql_error());
		}
		
		while($row = mysql_fetch_array($result))
		{
				if($row['customers_id'] == '$customers_id')
				{
						$admin_account = 'true';
						$admin_account_level = $row['account_level'];
				}
		}
	}
This script above checks to see if the $customers_id is set (which is set upon login), if this is true then,
$admin_account_level is set to whatever is in the database, this is the variable used to control if the box is displayed...

My next bit of code is related to how the actual box is selected,

[Filename: coloum_left.php]

Code: Select all

if(isset($admin_account_level))
	{
		if($admin_account_level = 1)
		{		// Administration Account Level ---> DISABLED For security reasons until a more secure way is found and implemented
			  require(DIR_WS_BOXES . 'admintools.class.php');
		}
		elseif($admin_account_level = 2)
		{		// Franchise Account Level
			  require(DIR_WS_BOXES . 'franchisetools.class.php');
		}
		elseif($admin_account_level = 3)
		{		// Wholesale Account Level
			  require(DIR_WS_BOXES . 'wholesaletools.class.php');
		}
		elseif($admin_account_level = 4)
		{		// Trade Account level
			  require(DIR_WS_BOXES . 'tradetools.class.php');
		}
		elseif($admin_account_level < 1)
		{
			  $admin_access = 'no';
		}
	}
The above code is in the coloum_left.php, basically this control's what is displayed depending on who is logged in and what there access level is......

Do you guys think this will work properly, or do you know of a better way to do the job that is required...
I would appreciate any help/support you can give me, of course this contribution will be distributed for free on the oscommerce site, to help make the community bigger and have more functions for the the vanilla oscommerce installations...

Thanks in Advance,


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
pilsy2001
Forum Newbie
Posts: 16
Joined: Tue Jun 20, 2006 8:00 pm

Post by pilsy2001 »

feel free to jump in anytime guys... :lol:
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Code: Select all

switch ($admin_account_level) {
    case 1: 
    //do something
    break:

    case 2:
    //do something else
    break;

    default:
    //do something else yet again

}
pilsy2001
Forum Newbie
Posts: 16
Joined: Tue Jun 20, 2006 8:00 pm

Post by pilsy2001 »

Jenk wrote:

Code: Select all

switch ($admin_account_level) {
    case 1: 
    //do something
    break:

    case 2:
    //do something else
    break;

    default:
    //do something else yet again

}
is this the code i need to use in the second file? how is the switch activated? is it possible to add a Param to the URL and use it with PHP_SELF?

Thanks
Post Reply