Hello Everyone,
I have wrote the following PHP in order to check if a user is banned from my website.
It works, however it is in my header file so it is included on everypage so it is executed every page and I would like a quicker process to quicken loading times.
Here is my code:
<?php
include("***/connect.php");
$selectbans = mysql_query("SELECT * FROM bans");
$currentuser = $_COOKIE['userloggedin'];
while($fetch = mysql_fetch_array($selectbans)) {
if($currentuser !== "") {
if($fetch['username'] == $currentuser) {
echo "<title>Banned! - You are banned</title>";
echo "<center>";
echo "<img src='images/banned.gif' />";
echo "<br><br>";
echo "<font face='arial'>";
echo "<table>";
echo "<tr><td> </td><tr>";
echo "<td align='center'><b>".$fetch['username'].", you have been banned for the following reason: <br /><br />";
if ($fetch['reason'] == "") {
echo '<font color="#FF0000">There is no reason specified.</font>';
}else{
echo $fetch['reason'];
}
"</b></td>";
echo "</tr></table>";
exit;
}
}
if($fetch['ip'] == $_SERVER['REMOTE_ADDR']) {
echo "<title>Banned! - You are banned</title>";
echo "<center>";
echo "<img src='images/banned.gif' />";
echo "<br><br>";
echo "<font face='arial'>";
echo "<table>";
echo "<tr><td> </td><tr>";
echo "<td align='center'><b>Your IP ( ".$fetch['ip']." ) has been banned for the following reason: <br /><br />";
if ($fetch['reason'] == "") {
echo '<font color="#FF0000">There is no reason specified.</font>';
}else{
echo $fetch['reason'];
}
"</b></td>";
echo "</tr></table>";
exit;
}
}
Thank you.