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
Run function every 5 mins ??
I have a function PostMessage()
How can I run it every 5 mins ??
iMatch stored value with the current value in a loop
Hello,
I have a MySQL db were I store articles in.
I have a form to fill these article
Displaying an image using echo command
I had done a query on my database, one of the fields being an image reference to a directory where a
Schedule editor
Hi,
I have a question related to Schedule editor.
If we schedule a BLS for every 30
help with image upload code
Hello,
right now this code I have resizes images and then places them into the uploads folder
BAPI BBP_INB_DELIVERY_CREATE - material number missing in delivery
Hi Experts,
I was able to successfully create an Inbound delivery with reference to a PO
SAP Management Console is blank
Dear All ,
I am facing problem in my des sever suddely in SAP Management Console is blank and
Help With editting and deleting form
Hallo !!
So look at this image :
http://img194.imageshack.us/img194/8272/snapshot5f.pn
Combining refCursors and Summing
Given the following DDL:
CREATE TABLE FOODSALESTEST
("WEEKNBR" NUMBER,
"ST
Update not working ... please help
Hi,
I am trying to update a row using an edit form by passing id of the row .. but it is not