A
Anonymous
Guest
Hi
I'm having a few problems with getting a part of a script working.
Here is the relevant code
Now my problem is with this part (I think)
If I am not logged on to my PHPnuke site I get the error "You need to Logon" & it exits as expected, this part works fine.
I want it so that if a user is logged on, it checks to see is their name in the managers table & if it's not they get the error "Your logged on but your not a directorate, bye!".
The problem is any user who is logged on to the site is told Your a Directorate! when they are not in my managers table
Can one of you experts take a look at my code & tell me if I'm doing something obviously wrong :wink:
Also, notice the way I have added a 2 after the variable names for the 2nd query, do I need to do that :?:
Thanks in advance for any replies
I'm having a few problems with getting a part of a script working.
Here is the relevant code
Code:
<?php
include("config.php");
include("header.php");
$dbh = mysql_connect ($dbhost, $dbuname, $dbpass) or die ( 'I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($dbname) or die (mysql_error());
// Perform query on travel table
$query = "SELECT * FROM travel";
$result = mysql_query($query) or die("Error:" .mysql_error());
//Authentication, user will not see results unless logged on
global $user, $sitename;
cookiedecode($user);
$username = $cookie[1];
if ($username == "") {
# $username = "Anonymous";
echo "You need to Logon";
exit;
}
else
{
echo "OK, Your logged on, now checking to see are you a directorate";
//Perform query on names of directorates
$query2 = "SELECT name FROM managers";
$result2 = mysql_query($query2) or die("Error:" .mysql_error());
while ($row2 = mysql_fetch_row($result2)) {
if (!$username == $row2[0]) {
echo "Your logged on but your not a directorate, bye!";
exit;
} else {
echo "<br>";
echo 'Your a Directorate!';
}}}
echo OpenTable();
// Retrieve values
while ($row = mysql_fetch_row($result)) {
###### Rest of Script goes here #######
Code:
$query2 = "SELECT name FROM managers";
$result2 = mysql_query($query2) or die("Error:" .mysql_error());
while ($row2 = mysql_fetch_row($result2)) {
if (!$username == $row2[0]) {
echo "Your logged on but your not a directorate, bye!";
exit;
I want it so that if a user is logged on, it checks to see is their name in the managers table & if it's not they get the error "Your logged on but your not a directorate, bye!".
The problem is any user who is logged on to the site is told Your a Directorate! when they are not in my managers table
Can one of you experts take a look at my code & tell me if I'm doing something obviously wrong :wink:
Also, notice the way I have added a 2 after the variable names for the 2nd query, do I need to do that :?:
Thanks in advance for any replies