I am trying to do what I think should be quite simple, which is to restrict user by "account type". I have setup a system based on Kevin Yank's "Manage Users with PHP Sessions" tutorial. I have added a field in my working database table, called "usertype" and added it to the registration page (data gets inserted into database, verified by checking MySQLAdmin).
I might add that I am using "enum" and pre-defined values (a.b.c) for my usertypes. Here is my sql:
So, on my restricted-access pages, I need to check if they are the proper user type, or let them know what the problem is. Here is my PHP:PHP Code:CREATE TABLE `user` (
`ID` int(11) NOT NULL auto_increment,
`userid` varchar(100) NOT NULL,
`password` char(16) NOT NULL,
`fullname` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`notes` text,
`usertype` enum('a','b','c') NOT NULL default 'b',
PRIMARY KEY (`ID`),
UNIQUE KEY `userid` (`userid`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
My user is registered as an "a" user, but I get the output: "You get options for a Super User" every time. I have tried to echo usertype in my HTML, but get no output (null). So, somehow, my retrieval script is not doing the job. Any help or suggestions?PHP Code:$sql = mysql_query("SELECT usertype FROM user WHERE id='$userid'");
while($row = mysql_fetch_array($sql)){
$usertype = $row["usertype"];
}
if ($usertype == "a") {
$userOptions = "You get options for Normal User";
} else if ($usertype == "b") {
$userOptions = "You get options for Expert User";
} else {
$userOptions = "You get options for Super User";
}
?>



Reply With Quote



Bookmarks