nickd_101 Posted September 3, 2006 Share Posted September 3, 2006 Hi,I was looking for help with distinguishing between user types on my website. I currently have a table in my MySQL database containing users, and within that table the "type" of user is identified (either agent or purchaser). I then proceed to initiate a session as normal, extracting the type column for each user as they login using $_SESSION['type']. This seems to function ok, when i use an echo, the PHP prints the user type out and it seems to work.However, i'm trying to restrict access to a page using an if statement so i haveif((@$_SESSION['auth']) && ($_SESSION['type']='agent')){//Show page content}else{//Don't show content}However, when i do this, the page restriction does not work. I've experiment with variations on the above code, and had success initially, but the $_SESSION['type'] actually appears to change itself when i modify the code on some occasions, e.g. I managed to get functionality as required when i used ...['type']!='purchaser'Any ideas as to the problem, or any suggestions as to an alternative method of distinguishing between member types. ThanksNick Quote Link to comment Share on other sites More sharing options...
.josh Posted September 3, 2006 Share Posted September 3, 2006 use == in an if statement, not === is the sign for equality= is the sign for 'assign' a value to somethingso when you do $_SESSION['type']='agent', if the first part of your argument is true (the 'auth' part), then the whole thing will be true, even if 'type' is really a purchaser, because your statement with one = actually assigns 'agent' to the 'type' (overwriting the previous value), so it will always come out true. other than that, you need to post some more code in order for us to see what else is going on Quote Link to comment Share on other sites More sharing options...
nickd_101 Posted September 3, 2006 Author Share Posted September 3, 2006 Hi,Thanks for the help. Made the correct modifications and it all works perfectly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.