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
What is SAP Avatar ?
Hi All,
This G.Satish , my boss asked me to explore on SAP Avatar. I searced in internet
Please help with code for SMTP authenticated PHP email form
Hello, I'm creating a PHP email form, and for this particular server, I have to use SMTP Authenticat
Searching keywords from array
Hello everyone, Im just wondering if someone could help me with another issue im having. Im still le
Login Script Issues
I am using a script I got from http://phpsense.com/php/php-login-script.html in order to allow peopl
limit string by words??
hello all,
I was wonder if there is a function to limit a string by the number of words inste
Is there a way to override built in php functions without APD?
I am trying to use the
rename_function()
override_function()
options that are built into
Calculating n! using vector
#include
#include
#include
using
unexpected T_VARIABLE error
Hey all! I'm getting an unexpected T_VARIABLE with the following function:
function getHighes
Problem with coding MySQL query
I'm having heaps of trouble getting one of my PHP/MySQL queries to work for some reason (and the fun
Preventing SQL Injection
I have a question about SQL Injection, In some of our code we use this:
view plaincopy to clipboa