Guernica Posted July 8, 2007 Share Posted July 8, 2007 I have a premium section of my site I am making. And I only want people with a value of "2" in the usergroup column to be able to view it. So on the pages what would I use for a code? I am pretty clueless at this part. Would it be like... $query = ... $result = ... $row = ... if($usergroup == 2) { echo "..."; } ... I have no idea where to start lol. Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/58947-solved-simple-ifmysql-question/ Share on other sites More sharing options...
Yesideez Posted July 8, 2007 Share Posted July 8, 2007 You've pretty much explained it right yourself. Pull the user's level from the table and check it. If it equals 2 (which is what you want to allow) then show the page. What I would add though is maybe redirecting the user to a different page if the value isn't equal to 2. <?php if ($usergroup==2) { //right value, show the page } else { header("Location: index.php"); exit; } ?> That way if the user doesn't have value 2 then they're redirected to index.php instead. Link to comment https://forums.phpfreaks.com/topic/58947-solved-simple-ifmysql-question/#findComment-292509 Share on other sites More sharing options...
Guernica Posted July 9, 2007 Author Share Posted July 9, 2007 I dont think it recognizes the variable $usergroup. I have: FIXED And I set my usegroup # to 2, and it still does the else echo of- Usergroup: 1. edit: I got it. Forgot to make a $usergroup = $row['usergroup']; thanks! Link to comment https://forums.phpfreaks.com/topic/58947-solved-simple-ifmysql-question/#findComment-292883 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.