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>";
}
php mysql script to find record
Hi, Currently I have a simple table with 4 columns. A, B, C, D If I want to find all the records with the similar value in column B. How can i write a simple query to match this one ? Please advise.
how to get different value in second view of webdynpro?
hello guys,
VAT
how should I deal with VAT?if I have a product that costs £5.00 and VAT @ 17.5% (£0.875) the total cost of the product is £5.875.so how do people deal with VAT should I round up/down? are
Confused with Loop
guys, i got confused with Looping...this is the caseI have 3 stocks, let say "Stock A", "Stock B", "Stock C" and the owner of each stock A --> Mr.Jamesstock B
script and html conflict in trying to create a header.
I have an error is occurring because of an html webpage with a "php require" at the top of the page calling a script. Somehow I'm having a problem with the html page and the script both
a function to check directory depth
I'm working on a php script to upload files in to a set directory.the user can select to upload into the "upload" directory or any of its subdirectories.at the moment the user is able to
Filtering for a phrase using pregmatch
Here is my code which looks for addresses which start with ' src=" 'Code: [Select]preg_match_all('#src="(http://[^"]+)#', $value, $matches)I want to modify this so that it only returns
Email Form Syntax Issue
I need the TO: in email to display To: CEO instead of To: abc@mail.comHow to alter the script below?Code: <?PHP$to = "abc@mail.com";$subject = "subject"; $headers =
Help with PHP Calendar code...
Hello, I'm new to this forum and I'm glad I found it.I wrote this code for a PHP calendar as an assignment for college.It works fine, but I also want today's day to show in another color and I can't
need help in update query
hi i have a dynamic form. i need help in how can i use update query when values from dynamic form get pass to php file.currently when i press submit it displays this and does not update fieldsCode: