john.muckley Posted April 29, 2013 Share Posted April 29, 2013 (edited) Hey guys, so i've got a create user form which allows new users to be created and added into the database as valid users for my site. as part of this form, you can select an access level, ie admin, manager, user. For some reason, no matter what i put here, the new user is always added as level 3 - which is user. I've read and reread the code and cannot see for the life of me why it is doing this! Can anyone help? Here is the php code which processes the new user request... $accesslv1=$_POST['accesslv']; //reading the POST variable from the create userpage //determine what access level this user has if(accesslv1=="admin"){ $accesslv=1; //this would be an admim user } elseif(accesslv1=="manager"){ $accesslv=2; //this would be a manager } else{ $accesslv=3; //this would be a user } for debugging, i popped this at the end instead of a redirect... echo "Username: " .$username . "<br> AccessLevel: " .$accesslv1 ." (lv" .$accesslv .")"; and all i get is this... Username: test1AccessLevel: manager (lv3) This should read manager (lv2), but for whatever reason its not doing! thanks in advance for any help guys!! Edited April 29, 2013 by john.muckley Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted April 29, 2013 Share Posted April 29, 2013 you probably have some code like - if($accesslv=3){} that is assigning 3 to the variable instead of code like - if($accesslv==3){} that is comparing 3 with the variable. Quote Link to comment Share on other sites More sharing options...
Solution cyberRobot Posted April 29, 2013 Solution Share Posted April 29, 2013 (edited) You're missing a few dollar signs in the if/elseif lines if(accesslv1=="admin"){ Edited April 29, 2013 by cyberRobot Quote Link to comment Share on other sites More sharing options...
john.muckley Posted April 29, 2013 Author Share Posted April 29, 2013 You're missing a few dollar signs in the if/elseif lines if(accesslv1=="admin"){ Haha!!! that was exactly it! thanks cyberRobot! 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.