Re: Login form + User level access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Carlos,

Something like this (assuming that the field with the type of the user
- admin, sales, etc. - is called `Status`, and the table is called
`Users`):
$f=mysql_fetch_assoc(mysql_query("SELECT `Status`, COUNT(*) AS
`UserExists` FROM `Users` WHERE
`Name`='".$_POST['name']."' AND
`Password`='".md5($_POST['pass'])."'"));
if ($f['UserExists']>0) { // name and password are correct
switch ($f['Status']) {
                     case 'ADMIN': include "adminmenu.php"; break;
                     case 'SALES': include "salesmenu.php"; break;
                     // ...
                     }
                     } else {
                     die ("You entered either an incorrect login or an
                     incorrect password.");
                     }
                     
                     I assume you store crypted passwords in your
                     database, and the algorythm is md5 (there are
                     better solutions, but I used it simply for this
                     example).

-- 
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

----- Original message -----
From: Carlos Sura <carlos_sura@xxxxxxxxxxx>
To: php-general@xxxxxxxxxxxxx <php-general@xxxxxxxxxxxxx>
Date: Tuesday, June 29, 2010, 10:46:14 PM
Subject:  Login form + User level access




Hello everyone.

I have this question: I'm developing a login system but what I need is to do is access levels

I mean, in my database I have this users:

Admin
Superusers
sales
purchase
etc

So, What I do basically need is, when a user from sales log in.. I want him to see just the menu from SALES, He cannot see others menu options, and he can't get access, I was reading that I can do that with  Switch,  but really I have no idea about it... Any help?

Thank you.

Carlos Sura.




 		 	   		  
_________________________________________________________________
http://clk.atdmt.com/UKM/go/197222280/direct/01/
Do you have a story that started on Hotmail? Tell us now


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux