Hi. I am having trouble with this script:
<?php
$host="mysql.host.com"; // Host name
$username="username"; // Mysql username
$password="password"; // Mysql password
$db_name="DB_NAME"; // Database name
$tbl_name="table"; // Table name
$myusername = $_SESSION['myusername']; // Session on login page, in a variable.
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Select everything that we need.
$sql = "SELECT * FROM $tbl_name WHERE username='$myusername' and banned='1'"; // Possible problem...I think....
$query = mysql_query($sql);
$row = mysql_fetch_array($query);
if($banned == 1) { // If the person on the table has the "1" value in banned, ban them..
header('Location: http://www.mywebsite.com/banned/banneduser.php'); // Ban page
} else {
// Their not banned... Let them in ..... Don't do anything...
}
?>
This code works, it's just not working properly. This code is supposed to redirect the user with the "1" value in the column "banned". Basicly, this script is supposed to "crawl" on the table and search for the user in the table with the "1" value in "banned", while the user is online, and redirect them to the "banned" page if the "banned" value is "1". The script currently does not redirect how I want it to. Instead, it lets the people that are banned online. I don't know why. I tried jumping through all the hoops, and never got it working. I would be glad if someone fixed it.