Jump to content

Recommended Posts

Hi all i have a ban script for my website but there is some kind of problem, here the script

 

<?php
include('config.php');
include('style.css');
include('functions.php');
session_start();
$username=$_SESSION['username'];
$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
$level=$fetch->level;

if($level > "owner"){

$ban=$_POST['ban_username'];
$time=$_POST['time'];
$reason=$_POST['reason'];
$type=$ban;

if(!$ban){
}else{
mysql_query("UPDATE users SET status='Banned' WHERE username='$ban'");

mysql_query("INSERT INTO `ban` (`id`, `username`, `by`, `type`, `reason`, `length`) VALUES ('', '$ban', '$username', '$type', '$reason', '$time')");

mysql_query("INSERT INTO `log` ( `id` , `by` , `action` , `level` ) 
VALUES ('', '$username', 'Banned $ban_username for reason $ban_reason', '$userlevel')");

echo "You banned $ban.";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=ban.php\">";
}
}

?>

<style type="text/css">
<!--
body,td,th {
color: #990000;
}
body {
background-color: #999999;
}
-->
</style><form name="form1" method="post" action="">
  <table width="67%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="<?php echo "$td_border"; ?>" bgcolor="<?php echo "$td_bg"; ?>">
    <tr> 
      <td height=22 background="<?php echo"$gradient"; ?>"><center class="TableHeading">
          <strong>Ban a user</strong> </center></td>
    </tr>
    <tr> 
      <td><table width="100%" border="0" cellspacing="3" cellpadding="0">
          <tr> 
            <td width="50%">Username</td>
            <td width="50%"><input name="ban_username" type="text" id="ban_username"></td>
          </tr>
          <tr> 
            <td>Length(Levae blank for permanent ban).</td>
            <td><input name="time" type="text" id="time">
              Hours</td>
          </tr>
          <tr> 
            <td>Reason</td>
            <td><textarea name="ban_reason" cols="40" rows="7" id="ban_reason"></textarea></td>
          </tr>
          <tr> 
            <td> </td>
            <td><input name="Ban" type="submit" id="Ban" value="Ban this user"></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
<p><br>
  <br>
</p>
</body>
</html>

 

When you put the in info in then click 'ban this user' nothing happends anyone know why?

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/171851-ban-script/
Share on other sites

if($level > "owner"){

 

is the same as

 

if ($level > 0){

 

What does $level contain? If $level contains a string (altough not entirely sure it's possible php performs an internal strcmp() but then again you'll get unexpected results as member > owner thus member may ban other members) you'll get

 

if (0 > 0) {

 

if(!$ban){
}else{

 

is the same as

 

if ($ban){

Link to comment
https://forums.phpfreaks.com/topic/171851-ban-script/#findComment-906160
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.