Redirecting Admin


Posted on 16th Feb 2014 07:03 pm by admin

In my members table, I have a field called "perm" and it's set to zero for all members. However, I have two administrators, and theirs are set to 1.
I want my members page that shows up on login to redirect admins if their "perm" number is set to 1
Right now it's not having any errors, but it's not redirecting the admins.

Thank you!

Full code:
Code: <?php
// Connects to your Database

...

//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_staples_clubs']))
{
$username = $_COOKIE['ID_staples_clubs'];
$pass = $_COOKIE['Key_staples_clubs'];
$check = mysql_query("SELECT * FROM members WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{

//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location: login.php");
}

//otherwise they are shown the member area
else
{
$query = "SELECT clubs.*, members.* FROM clubs LEFT JOIN members ON members.club = clubs.id WHERE members.username = '{$_COOKIE['ID_staples_clubs']}'";
$result = mysql_query($query) or die(mysql_error());

while ($row = mysql_fetch_array($result)) {
//admin
if ($row['perm'] == 1) {
header("Location: admin.php");
}

//member
else {
echo "$row[name] <br />";
echo "Welcome, ";
echo "$row[adv] <br />";
echo "<a href=edititem.php?id=$row[club]>Edit Club</a>";
echo "<br />";
echo "<a href=changepass.php>Change password</a><br />";
echo "<a href=logout.php>Logout</a>";
}
}
}
}
}
else

//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>
Troublesome part:
Code: while ($row = mysql_fetch_array($result)) {
//admin
if ($row['perm'] == 1) {
header("Location: admin.php");
}

//member
else {
echo "$row[name] <br />";
echo "Welcome, ";
echo "$row[adv] <br />";
echo "<a href=edititem.php?id=$row[club]>Edit Club</a>";
echo "<br />";
echo "<a href=changepass.php>Change password</a><br />";
echo "<a href=logout.php>Logout</a>";
}

225 Like 16 Dislike
Previous php-forum Next php-forum
Other php-forum

Remove values in array2 from array1
I have two arrays.

Array 1 is where the array key holds various different numbers. For exampl

how to read and write into a word document using php...?
hi,
I need,reading and writting into a word document using php.




Thank u inadva

rename the file
File.txt

Code: ***DOCUMENT***
..DN:
000044255
..CB:
..SN:
..PY:
2009
..E

Storing the referrer in session... problems with tabs
Hello All

I am currently working on an ERP project based on the MVC methodology, when a user

Coding Critique
I was hoping someone could take a second and look down my code and see if they see any problems with

rdns with php
I am trying to build a script that will show all of the different domains that are hosted on the sam

Curl & sessions PLS HELP
Hello,

I have a problem with curl and sessions and i will try to explain the best i could.

Cant display mysql data
Hey all,

I am learning php and my first goal is to create a simple CMS. At the moment I am st

form variables from database help.
Hi all,

I would like to have a form that gives you options based on the results of an mysql q

Login page problems
I developed a website a few months ago and I am now having an issue with logging into it. The place

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash