Rifts Posted November 6, 2009 Share Posted November 6, 2009 Hey guys im having trouble writing a simple script to check if the user with member_id 1 is the one trying to access the page. thanks Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted November 6, 2009 Share Posted November 6, 2009 More info would help. do you have the admin info/id saved in a session? Quote Link to comment Share on other sites More sharing options...
Rifts Posted November 6, 2009 Author Share Posted November 6, 2009 here is what i have so far... im pretty new to this stuff so be kind =] the first part I think checks to see if ANYONE is logged in and the second was to check if user with member id 1 is logged in but it doesnt work //Check whether the session variable SESS_MEMBER_ID is present or not if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) { header("location: access-denied.php"); exit(); } //Check to see if admin is logged in if(member_id=='1') { header("location: adminauth.php"); }else { header("location: index.php"); } Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted November 6, 2009 Share Posted November 6, 2009 //Check whether the session variable SESS_MEMBER_ID is present or not if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) { header("location: access-denied.php"); exit(); } $member_id = $_SESSION['SESS_MEMBER_ID']; //Check to see if admin is logged in if($member_id=='1') { header("location: adminauth.php"); }else { header("location: index.php"); } Quote Link to comment Share on other sites More sharing options...
Goldeneye Posted November 6, 2009 Share Posted November 6, 2009 Basing Administrator status on what the user-ID is, isn't the best way to have an administration echelon. Instead, have an ENUM field in your database called `admin` with either 0 (or not admin) and 1 (or is admin. That is a very primitive way, as well but it is leaves room for more flexibility. Also, member_id should be $member_id. Quote Link to comment Share on other sites More sharing options...
Rifts Posted November 6, 2009 Author Share Posted November 6, 2009 ok new problem.. I think that code worked but it get this now This webpage has a redirect loop. The webpage at http://localhost/homepage/activation-form.php has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer. Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted November 6, 2009 Share Posted November 6, 2009 strange. change it to //Check whether the session variable SESS_MEMBER_ID is present or not if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) { header("location: access-denied.php"); exit(); } $member_id = $_SESSION['SESS_MEMBER_ID']; //Check to see if admin is logged in if($member_id=='1') { header("location: adminauth.php"); exit(); }else { header("location: index.php"); exit(); } Try it like that it depends what is in the files index.php and adminauth.php. do any of those pages redirect to this page? Quote Link to comment Share on other sites More sharing options...
Rifts Posted November 6, 2009 Author Share Posted November 6, 2009 ahhh i think i fixed it... I just changed it so I go to adminauth.php instead of activation-form.php then if adminauth.php comes back that its the admin it fowards me to activationform.php thank you for all the help!! I really appreciate it! Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted November 6, 2009 Share Posted November 6, 2009 ah cools 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.