Have an account? Sign in
Login  Register  Facebook
How to create php login with 3 fileds?
How to create php login with 3 fileds?
I need to create Login script
with 3 fields
1. Username or Email
2. Password
3. User group drop down selection
[there are 5 usergroups. webmaster ,Admin, Agent, Customer, staffs]

Webmaster can access everything, all other have limited access to main Admin panel and Agent could only access his profile and his entry. Customer can access to modify only his
Started: September 18, 2011 Latest Activity: September 18, 2011 php login
1 Answer
ok will give the basic idea of the groups system you can look at this article
and this is small explation of how this work:
first you must make an table in your database to save the group just such as \'user_geoups\'

Table structure for table `user_geoups`

CREATE TABLE `user_groups` (
  `group_id` int(11) NOT NULL AUTO_INCREMENT,
  `group_name` varchar(255) COLLATE utf8_bin NOT NULL,
  `admin` int(11) NOT NULL,
  PRIMARY KEY (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

Table structure for table `users`

CREATE TABLE `users` (
  `user_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_name` varchar(255) COLLATE utf8_bin NOT NULL,
  `group_id` int(11) NOT NULL,
  PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;
now when you determine the user to select from the database you have to use something like this to make the authentication
//you will get this id by the login form using cookies or session
$user_sql = @mysql_query(\"select * FROM `users` where user_id = \'1\'\");
$user = mysql_fetch_array($user_sql);

//now we get the group with the same method
$group_sql = @mysql_query(\"select * FROM `user_groups` where group_id = \'\".$user[\'group_id\'].\"\'\");
$group = mysql_fetch_array($group_sql);

    if (!$group[\'admin\']) {
        exit(\'you is not the admin\');	
    }
and if you want a full system to do that you can look here

Posted: MacOS
In: September 18, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer