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>";
}
No comments posted yet
Your Answer:
Login to answer
225
16
Other forums
How to Create a Dynamic table
col1 col2 date1 date2 date3 date4..........
a b v1 v2 v3 v4
Grouping and sorting results
Please help with this query.
I have 2 tables in a database, countires and cities. states look
Progress bar tracking file downloads
Hey guys, was wondering if there was a way to track how far a file has been downloaded. I know there
Security Exception on pages using AJAX
I am getting the exception: attempted to perform an operation not allowed by the security policy on
Rand() help needed
Hi all,
Can someone explain and give me a quick example of how I would go about this?
DATEDIFF Question
First time post, and of course it is a help question.
I am using a WP plug-in to display prev
path to include folder
Hi everyone,
When I'm testing locally, I have to add the name of the site folder as part of t
How do i do multi uploads?.
Hey i would like to do this : http://hosting.mrkrabz.net/
I've got the base down you can uplo
CURL XML Request [From C to PHP]
Hi,
I need some help converting this into something that will work with PHP.
Code: #
Multi dimensional arrays
If I put in this code:
1
2
3
4
5
6
7
8
9
10
11
12
13<