prcollin Posted June 5, 2008 Share Posted June 5, 2008 I want to put a hit counter on my website that is only visible to the administrators. Can i just do along the general lines of if user == 'blah' counter.visible = 'true' Or how would you echo a visible counter? I haven't worked that out yet lol elseif user == 'blah1' counter.visible = 'true' else counter.visible = 'false' Ill post full code as soon as I generate it the idea just popped into my head and wanted to get your opinion on the best way to make it visible to only two users Link to comment https://forums.phpfreaks.com/topic/108840-solved-hidden-hit-counter/ Share on other sites More sharing options...
jonsjava Posted June 5, 2008 Share Posted June 5, 2008 simplest way is to give each user level a numerical value in the db, so you can just do this: (example code -- rework to suit your needs) <?php if ($_SESSION['user_level'] == "admin"){ //put your counter code here } ?> You don't need an else statement. If you want more than one user group to see it: <?php if ($_SESSION['user_level'] == "admin" || $_SESSION['user_level'] == "moderator"){ //put your counter code here } ?> Link to comment https://forums.phpfreaks.com/topic/108840-solved-hidden-hit-counter/#findComment-558288 Share on other sites More sharing options...
craygo Posted June 5, 2008 Share Posted June 5, 2008 you can also make the counter it's own page then use jons code to include the page <?php if ($_SESSION['user_level'] == "admin"){ //put your counter code here include('counter.php'); } ?> Ray Link to comment https://forums.phpfreaks.com/topic/108840-solved-hidden-hit-counter/#findComment-558291 Share on other sites More sharing options...
prcollin Posted June 5, 2008 Author Share Posted June 5, 2008 excellent. Thank you very much. Working on a new CMS and I want it to have ultimate functionality so I may have more questions in the future. As always you guys are great! Link to comment https://forums.phpfreaks.com/topic/108840-solved-hidden-hit-counter/#findComment-558298 Share on other sites More sharing options...
jonsjava Posted June 5, 2008 Share Posted June 5, 2008 Please mark this topic solved. Link to comment https://forums.phpfreaks.com/topic/108840-solved-hidden-hit-counter/#findComment-558311 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.