Jump to content

Checking to see if admin is logged in


Rifts

Recommended Posts

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");
}

Link to comment
Share on other sites

//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");
}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.