ok this is what i am trying to do if $user is lower than $userlevel then i want it to carry on with the page if not i want it to print a message then stop doing anything
this is the include source for the page
<?
$userlevel = "4"; //set the user level
require("check.php")
?>
this is the code for check.php
<?
// database configuration
$host = "localhost";
$user = "root";
$pass = "";
$db = "test";
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// generate and execute query
$query = "SELECT level, name FROM login WHERE name = '$usernamecookie' AND password='$passwordcookie'";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
if(mysql_num_rows($result) > 0) {
//if the username is checked out correctly check for valid level
$row = mysql_fetch_row($result);
$level = $row[0];
echo "$level - $userlevel <br><br>";
if($level < $userlevel); {
echo "only admins and senior members can see this";
die('');
}
//if valid - continue with page
}
//if user in NOT valid then terminate the script
else {
die('tut tut tut');
}
// close database connection
mysql_close($connection);
?>
if any one can think of a better way to accses the DB then please say aswell