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

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

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.

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.

 

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?

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.